Hello,
I am trying to debug one of my HTML Applications that stopped working all of the sudden. Let me tell you the problem. Features in my application depend on cross domain scripting. For those of you that don't know, an example of cross domain scripting is when you access data from another domain using javascript, the DOM and probably an IFRAME or FRAMESET. Well, my application used to work and now it doesn't. The example that I will provide below uses the same technique that I used in my application and I swear it worked before I upgraded from IE 5 to 6!
Copy the code below to an .hta file and execute it. The application asks for an URL. Type in your favorite URL and click the 'go' button. Then, using the left button of the mouse, select some text from the web page and click the 'Get Text' button. The application is suppose to alert you with the text that you selected from the web page. This example used to work, and I desperately need a workaround!
The HTA File:
<html>
<head>
<TITLE>HTML Application Example</TITLE>
<HTA:APPLICATION ID="HTAEx"
APPLICATIONNAME="HTAEx"
ICON="e.ico"
WINDOWSTATE="normal">
</head>
<body>
<span id=AddressBar style="overflow: none">
<span id=AddText>Address</span>
<input type=text value='' id=TheAddress style="width: expression(document.body.clientWidth - AddText.offsetWidth - AddGo.offsetWidth - 45)">
<input type=button value="Go" id=AddGo onclick="navigate()">
<br><input type="button" value="Get Text" onClick="getText()"><br><span><br>
<iframe src="" id="TheFrame" style="width: 100%; height: 85%"></iframe>
<script language=JScript>
function navigate()
{
document.all.TheFrame.src = TheAddress.value;
}
function clickShortcut()
{
if (window.event.keyCode == 13)
{
navigate()
}
}
TheAddress.onkeypress = clickShortcut;
function getText()
{
var doc = window.frames.TheFrame.document;
var text1 = doc.selection.createRange().htmlText;
alert(text1);
}
</script>
</body>
</html>
Sincerely,
aspmonger