Page 1 of 1
(JS) IE gets busted after download.
Posted: Mon May 05, 2003 8:13 am
by Heavy
When I use this function:
Code: Select all
//JavaScript:
function DownloadFile(ID){
document.location = 'file-download.php?ID=' + ID
}
...a dialog appears, which offers me ways to download the file. This works alright in both Mozilla and IE6.
Problem (with IE of course):
But when the file is downloaded and I move the mouse back to the page, eveything is broken and I get lots of JS-errors. The only immediate solution to the problem is to reload the page.
What gymnastics should I do to trick IE into working as expected, which is, to run the page continuously without errors, no matter how many times I click the download button?
This is because the page offers several downloads from a mysql database and I don't want users to have to reload the page after each download.
Posted: Mon May 05, 2003 8:15 am
by Heavy
I might add:
I have browsed the msdn.microsoft.com for about an hour without getting anywhere.
Posted: Mon May 05, 2003 8:15 am
by []InTeR[]
How do you call this function?
From a onClick or in a url?
Posted: Mon May 05, 2003 8:20 am
by Heavy
Code: Select all
<td class="buttontd"><img src="img/file-download.png" id="DownloadButton" border="0" title="Click to download" onclick="DownloadFile(ActiveID)" class="hoverbutton" ></td>
ActiveID is a JS-var that is set erlier, before the user sees this. As I said. It works in both IE and MZ, but whet the download is finished, IE just produces a mess of JS-errors.
I guess there is a way how things should be done. A way I'm currently not on...
Posted: Mon May 05, 2003 8:26 am
by []InTeR[]
Maybe it has something to do with return values, but it's just a wild gues.
Can we see the whole content? Or a link to the real page.
Posted: Mon May 05, 2003 8:35 am
by Heavy
Code: Select all
<body onmousemove="GetMouseCoords()" onload="InitPage()" id="Body" >
and
Code: Select all
function GetMouseCoords(){
Now.X = window.event.clientX + document.getElementById('Body').scrollLeft
Now.Y = window.event.clientY + document.getElementById('Body').scrollTop
MovePopupInfo()
}
function MovePopupInfo(){
if (IsFile){
if (document.getElementById('PopupInfo_MoveFile') != null){
document.getElementById('PopupInfo_MoveFile').style.left = (Now.X + 10) + 'px'
document.getElementById('PopupInfo_MoveFile').style.top = (Now.Y + 10) + 'px'
}
}else{
if (document.getElementById('PopupInfo_Move') != null){
document.getElementById('PopupInfo_Move').style.left = (Now.X + 10) + 'px'
document.getElementById('PopupInfo_Move').style.top = (Now.Y + 10) + 'px'
}
}
}
There is something more in the page related to the "body.keyup"-event. But as the page steps on its skirt without me pressing any keys, I left that out.
Posted: Mon May 05, 2003 8:45 am
by []InTeR[]
Okay, lets not fix the problem....
Change the
Img code to:
Code: Select all
<td class="buttontd"><A HREF="file-download.php?ID=<? echo $id ?>><img src="img/file-download.png" id="DownloadButton" border="0" title="Click to download" class="hoverbutton"></A></td>
Try this

.
I think that the body onload not is triggert when you hit the back button to activate the window. And IE thinks you left the page, becouse the document.location.
PS: issen't that document.location.url = 'file.html';
Posted: Mon May 05, 2003 9:40 am
by Heavy
PS: issen't that document.location.url = 'file.html';
Nope.
Code: Select all
//JavaScript:
function DownloadFile(ID){
document.location = 'file-download.php?ID=' + ID
}
PHP opens a mysql connection and sends the content of a virtual file with identification number = ID.
As I told you. That part of everything works just fine. It is off the topic how the file is retrieved. It is on the topic whether the triggering function could or should be something else for getting IE to work properly.
I could workaround by doing this:
Code: Select all
//JavaScript:
function DownloadFile(ID){
window.open('file-download.php?ID=' + ID,'popupwindowname')
}
But right now I am asking the world about specific instructions on how to do this the correct way, as fas as Microsoft is concerned.
As said before, I have searched the msdn network without finding the solution.
Posted: Mon May 05, 2003 9:47 am
by Heavy
[]InTeR[] wrote:
I think that the body onload not is triggert when you hit the back button to activate the window. And IE thinks you left the page, becouse the document.location.
Partly correct... Maybe.
I don't click any back button. I just move the mouse back to the page displayed.
Posted: Mon May 05, 2003 10:19 am
by []InTeR[]
A correct way with M$?
Nope, can't do.
Aslong as it works, and the source is neath.
Posted: Tue May 06, 2003 2:15 am
by Heavy
IE tends to feel very buggy. Some bugs are real, some appear because of the web developer creating things out of spec. That doesen't mean MS lack of standards. They have just decided to go their own way.
By the way, I like very much the way that MS writes documentation (API docs). They have lots of cross-references and cover the topics pretty well.
Lack of such is the one of the few flaws of the Open Source Community. (Yeah, someone will blow me away for this. Admit it. Documentation could be better. But don't ask me do it, cause I am fed up with computers already. I do what I have to. The rest of my efforts go into music and electronics.)
Now... I am not even looking for a W3C-compliant way to preform that file download. (I have given up on that) But I am looking for the MS way to do is correctly.
Anybody?
Posted: Tue May 06, 2003 7:37 am
by volka
I tried to reproduce the error but couldn't.
Maybe if you provide a working code snippet that causes such an error...
What are you trying to do?
I'm guessing you want to show something like a detail layer whenever the mouse is over a certain element. If so fetching the onmousemove event for the whole body might not be the best way.
Posted: Tue May 06, 2003 9:35 am
by Heavy
I don't have the time for this right now, but here's (kind of) the error message:
"Permission denied"
What I do when the mouse moves is to reposition a table with the following style:
Code: Select all
table.popup {
background:rgb(255,240,220);
border: 2px solid rgb(164,100,100);
border-radius: 6px;
-moz-border-radius: 6px;
position:absolute;
left:40px;
top:100px;
}
The table is hidden by default:
Code: Select all
<table class="popup" id="PopupButtons" style="display:none;" >
It works all the time except for when the following code has been executed in IE:
Code: Select all
function DownloadFile(ID){
document.location = 'file-download.php?ID=' + ID
}
I have worked around this for now, using the following instead:
Code: Select all
function DownloadFile(ID){
window.open('file-download.php?ID=' + ID)
}
Right now,
this is a bigger problem...