Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey guys I need to get a javascript that wil make it so when someone clicks on a link on my webpage a window with the corresponding information pops up in front, they can read it then X out of it. I thought I found a good script but I cannot get it to work. I need this for 2 different links on the same page....here is what I got so far...
{head}
[script language="JavaScript"]
[!-- Hide from old browsersfunction winopen(){
window.open('cdl.html', 'NewWindow1','toolbar=yes,location=yes,directories=no,
status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes,
width=635,height=260')
window.open('labor.html', 'NewWindow2','toolbar=yes,location=yes,directories=no,
status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes,
width=635,height=260')
}
// -->
[/script]
{head}
{body}{/body}
basically if someone clicks on the cdl link a window pops up describing the job and the same with the laborer...any help would be appreciated.

The problem is that you are referencing a href value in your anchor tag (i.e. A tag).
Your link should be something like this:
Note, you should add the "return false" to the onclick value to prevent the main page from refreshing - which would make the page scroll to the top.

Let's try again replacing the < & > with brackets:
[a href="#" ONCLICK="winopen();return false;"]CDL Drivers[/a]

Michael, I did the return false cose which was actually going to be my next question but now I need to know how to get this to work, I click the link and nothing at all happens...any ideas.

See if this works for you. Just change the [&] brackets to < & >, change the webpage name parts to your webpage, and make changes to the window elements you want to show or hide or resize.
[a onClick="MyWindow=window.open('WebPageName.htm','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600,left=1,top=1'); return false;" href="WebPageName.htm"]
Link Text[/a]

You must have a typo somewhere, it works for me. Try this code - use find/replace to change the [] to <>.
[html]
[head]
[script language="JavaScript"]
function winopen(){
window.open('cdl.html', 'NewWindow1', 'toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes,width=635,height=260');
window.open('labor.html', 'NewWindow2', 'toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes,width=635,height=260');
}
[/script]
[/head][body]
[a href="#" ONCLICK="winopen();return false;"]CDL Drivers[/a]
[/body][/html]
Michael J

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |