PDA

View Full Version : Pop up from a pop up problem


Dalsor
12-14-2002, 11:16 PM
Greetings,

I'm re-tooling the pages for the ISP I work for, and in the process of doing so, adding a bunch of user helps. Part of these helps is to explain what dial-up modems, DSL modems, etc., are, what they look like, where to plug the lines in ... you get the idea. I thought the best way to do this would be with a combination of text and optional pop up pictures. Read the text, click the link for a picture in a pop up window kinda deal.

The initial pop-up from the main page (click here for more extensive help) works fine. It opens the help window. Within the newly created help window there are subsets of links which use the same javascript code to pop up another window with a picture in it. Though the script will open the new help window fine, it will not open a new window from the help window. The window with the picture always opens in the help window.

I hope I'm making sense. :D

Here's how I'm doing it.

Here is the script used throughout each page. This same script is in the head tags of every page, including the help pages.

Header comments trimmed for space... It's from Dynamic Drive.

<script type="text/javascript">
var win = null;
function helpPopWindow(mypage,myname,w,h,scroll)
{
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
</script>


Big main window (index.shtml).

<a href="hlp/netHlp.shtml" onclick="helpPopWindow(this.href,'Internet Help','650','550','yes'); return false">?</a>


When that link is clicked, the help window (netHelp.shtml) is loaded as a pop up. That works fine.

Within the pop up window there are several links, such as...


click <a href="modemAngle.jpg" onclick="helpPopWindow(this.href,'Internal Modem Angle View','360','270','yes'); return false">here
for an angled view</a> of an internal dial-up modem


But when this link is clicked, the image opens in the help window, and not in a new window. I thought it might have something to do with calling an image instead of a new document, but even placing the image in a document and calling the document through the href ends with the same result.

Can anyone see what I might be doing wrong?

Sorry for the formatting. :o

Thanks!

joh6nn
12-15-2002, 09:41 AM
hard to say what's wrong. from the code you've posted, it looks to me like everything is in order. which means we'll probably need to see the rest of the code you're working with.

cheesebagpipe
12-15-2002, 10:25 AM
Just a quick guess...

This: 'Internet Help'
...is not a valid name for a window.
Neither is this: 'Internal Modem Angle View'.

Spaces aren't allowed (use underscores if needed). If the names are failing, the browser will see each window as the same one (nameless) and open the links in the same one. Just a guess.

joh6nn
12-15-2002, 10:41 AM
good call. i didn't spot that. it wouldn't surprise me if that was the problem.

Dalsor
12-17-2002, 12:34 AM
Ah! That was it. Took the spaces out of the names and now I got nifty little pop-up pictures.

Thanks for the help! :thumbsup:

whammy
12-17-2002, 12:53 AM
Is that a Murphy's Law signature in code? Neat. ;)

Dalsor
12-17-2002, 01:04 AM
Yeah. Sometimes I get these crazy ideas and on ocassion, they're amusing enough to keep. ;)

chrismiceli
12-17-2002, 03:47 AM
you could have spaces if you escaped it
test = escape("Internal Modem Angle View");
onclick="helpPopWindow(this.href,test,'360','270','yes'); return false"
just thought you should know.

glenngv
12-17-2002, 09:14 AM
yes he could have escaped it but still the target will contain an invalid character %. The only allowed special character, I think, is underscore.