Click to See Complete Forum and Search --> : parent window, stay still!


miller
01-22-2003, 06:06 AM
i have a page that displays a table with info from a database.
each entry has a link for a popup-window displaying a photo.
the pop-up itself works fine. however, as soon as the pop-up
is displayed the parent window automatically scrolls to the
top, i.e. you have to scroll down again to where you were. this
window, btw, is part of a frameset. how do i get it to keep it's
position?! what am i missing?

thanks in advance,

miller

------------------------------------
the function in the header:

<SCRIPT Language="JavaScript">
<!--
function popup(link)
{
popupWin = window.open('', 'ShowMenu', 'width=420,height=350,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,left = 130,top = 100');
// focus window (only for > Navigator 3.0)
if ((navigator.appName != "Microsoft Internet Explorer") && (navigator.appVersion.substring(0,1) == "3"))
popupWin.focus();
popupWin.document.write('<TITLE>'+ link +'</TITLE>\n');
popupWin.document.write('<BODY Bgcolor="#000000">\n');
popupWin.document.write('<CENTER>\n');
popupWin.document.write('<IMG Src="../images/food/' + link + '">\n');
popupWin.document.write('<br><a href="javascript:window.close();"><font color="#993333" face="Verdana, Arial, Helvetica, sans-serif" size="-1">close window</a>\n');
popupWin.document.write('</font></CENTER>\n');
popupWin.document.write('</BODY>\n');
}
-->
</script>


------------------------------------
this is in the body:

<A Href="#" onClick="popup('<%=rs("foto_r")%>');" onMouseover="msg('Show Picture'); return true;" onMouseout="msg('');">
<img src="../images/fotoex.jpg" border="0"></a>


non-important note: rs("foto_r") is a variable with the name of the photo i wish to display in the pop-up.

gil davis
01-22-2003, 06:10 AM
Originally posted by miller
how do i get it to keep it's position?! what am i missing? ...
<A Href="#" onClick="popup('<%=rs("foto_r")%>');" onMouseover="msg('Show Picture'); return true;" onMouseout="msg('');">
Do you know where the anchor "#" is in your document? Neither does the browser. It is a null location, so the browser sends the page back to the top. This is the default action of an anchor.

Cancel the default click action of the anchor by adding "return false" to the onclick handler. Thus:

<a href="#" onClick="popup('<%=rs("foto_r")%>');return false" ... >

miller
01-22-2003, 07:41 AM
thanks for the quick reply gil,

i tried with 'return false;', however, the problems remains
the same. any other suggestions?

miller

gil davis
01-22-2003, 07:54 AM
I didn't catch the nested quotes:

<a href="#" onClick="popup('<%=rs("foto_r")%>');return false" ... >Should be:

<a href="#" onClick="popup('<%=rs(\"foto_r\")%>');return false" ... >

If that doesn't fix it, the problem must be in the resolution of

<%=rs("foto_r")%>

Apparently an include of some kind that I'm not familiar with.

pyro
01-22-2003, 07:58 AM
gil davis's suggestion works fine for me in IE6, NN7, Mozilla 1, and Opera 7. You sure you did it right?

miller
01-22-2003, 08:16 AM
Originally posted by gil davis
I didn't catch the nested quotes:

Should be:

<a href="#" onClick="popup('<%=rs(\"foto_r\")%>');return false" ... >

If that doesn't fix it, the problem must be in the resolution of

<%=rs("foto_r")%>

Apparently an include of some kind that I'm not familiar with.

well, everything within the <%%> tags are server-side scripts and does not really have anything to do with the javascript itself. in this case <%=rs("foto_r")%> will produce the name of the photo (example.jpg) before reaching the browser - this i have checked and verified and the pop-up displays just fine. this is the actual code taken from the browser using 'view source':

<A Href="#" onClick="popup('roll23.jpg');" onMouseover="msg('Show Picture'); return false;" onMouseout="msg('');">
<img src="../images/fotoex.jpg" border="0"></a>


Originally posted by pyro
gil davis's suggestion works fine for me in IE6, NN7, Mozilla 1, and Opera 7. You sure you did it right?
yup, doublechecked the code :-). both ie6 & nn7 move the parent window up.

pyro
01-22-2003, 08:36 AM
Try this. It works fine for me in all the noted browsers. Note: I _did_ delete out your ASP code, as that wouldn't work for me anyway....

miller
01-22-2003, 09:03 AM
thanks guys,

i copy&pasted from the zip file and i noticed a syntax error in my code :o - oh no...kicking myself... well everything works perfectly now:p

thanks again for the quick replies!

miller
01-22-2003, 12:58 PM
as long as script debugging is disabled in my browser all looks fine, though one annoying thing remains. i gather that you guys know that when debugging is disabled you can click lower left corner (in IE) for error messages and this is what i get (using pyro's zip in this case):

Error: Object Expected

appearantly in this line:
<A Href="#" onClick="popup('nowhere.jpg');return false;" onMouseover="msg('Show Picture'); return true;" onMouseout="msg('');"> hfd
<img src="../images/fotoex.jpg" border="0"></a>

i'd be glad to feed it whatever object it craves but am not sure how to solve this.

thanks in advance once again,
- miller

pyro
01-22-2003, 01:10 PM
I'm guessing it's a problem with your mouseover msg() function. When I removed that it worked fine. What's that code look like?

miller
01-22-2003, 01:56 PM
i got rid of that part as well, pyro,
and no more errors - didn't really
need that part anyway, so....

thing seems to be fine right now!

thanks again.:)