Forum Moderators: open

Message Too Old, No Replies

Javascript not working in IE only

         

doodlebee

2:20 am on Sep 14, 2006 (gmt 0)

10+ Year Member



Hello all -

I've been trying to figure this out for days now - and I'm hoping a guru here can help me with this.

Basically, I coded a site that needed a certain functionality:

1) click on link. Link opens a popup window, asking the end user to "Agree" or "Disagree" with it's contents (licensing agreement).

2) Upon clicking "disagree", the popup window closes, and the end user is returned to the home page. However, on clicking "Agree", the popup window closes itself and the parent window changes to a secondary page of instructions. When this page is loaded, there is an "onload" function in the lead <body> tag that brings up the standard "Save file as" box to download an .exe file.

I know the code I did probably isn't th ebest way to handle things, but I'm very newbie-ish when it comes to javascript - the original coder flaked on my boss and they needed something in a real hurry, so I did what I could. It's for an internal network, also, so it's not like it's gonna be out there for the world to get.

Anyway, the thing works fine in every browser and platform I've got to test it on (and believe me, I have *plenty*) except IE6 on PC. What happens is, when the end user clicks "I agree", the popup closes (as it should); the parent window changes to the page of instructions (as it should); but when the page full yloads (and the download should begin), the download fails and the page goes to a 404 "page not found".

I do not understand *why* Only IE would do this. The file is there (you can access it directly from every browser except IE), the path is correct - and yet IE *always* returns this error.

Could someone take a look at my javascript and see what could possibly be doing this? I'd really appreciate it.


Page 1:
(inside the header)
<script type="text/javascript">
function newWindow(file,window) {
msgWindow=open(file,window,',screenX=0,screenY=0,width=600,height=600,scrollbars=yes');
if (msgWindow.opener == null) msgWindow.opener = self;
}
</script>

(at the bottom of the page, in the body)
<a href="#" class="style13" onclick="javascript:newWindow('agreement.html','window2');">
Proceed to download</a>


Agreement.html (the popup window)

(in the head)

<script type="text/javascript"><!--
function load(file,target) {
if (target!= '')
target.window.location.href = file;
else
window.location.href = file;
}
//--></script>

(at the bottom of the page, in the body)

<input type="submit" name="Submit" value="I Agree" onclick="javascript:load('step2.html',top.opener);window.close();" />


Step2.html - the page that loads and starts the download
(but goes to 404 and no download in IE)

(in the body tag)
<body onload="javascript:window.location='http://www.domainnamehere.com/filename.exe'">

If anyone has any insight as to why this is, I would very much appreociate it.

daveVk

5:04 am on Sep 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



REPLACE

<body onload="javascript:window.location='http://www.domainnamehere.com/filename.exe'">

WITH

<body>
<iframe src="http://www.domainnamehere.com/filename.exe" height="0" width="0">

I assume this is the issue, neither solution looks clean to me as the intent is not to load any page content. Anyway worth trying.

doodlebee

11:31 am on Sep 14, 2006 (gmt 0)

10+ Year Member



Thank you Dave :)

That did keep the main browser window from turning into a 404 page - however the file still won't download.

This is so odd to me. I wonder why IE is the only browser that refuses to acknowledge the file for download?

Edit: Interesting. I just replaced the file for experiemental purposes - changed it from an .exe to a .zip file. Now it works.

So I'm wondering now if it's one of two things: either the file needs to be in the same folder (the inital file is not), or it needs to be zipped? POssib;y a security setting in IE? Hmmm...

doodlebee

3:44 pm on Sep 14, 2006 (gmt 0)

10+ Year Member



Okay, just wanted to update on this because I think I found the answer. I had a few people on a mailing list I'm on check it - and the ones that had lower security settings in IE (mine are pretty high) could get the file just fine with the original code.

So it turns out it's some kind of browser setting on the user's end. Just thought I'd mention it, in case anyone else has this issue.

Thanks a bunch fror the assistance, though!