Computing.Net > Forums > Web Development > java script pop up

java script pop up

Reply to Message Icon

Original Message
Name: BigShow
Date: July 24, 2005 at 18:34:52 Pacific
Subject: java script pop up
OS: xp
CPU/Ram: amd athlon 700mhz,256 k
Comment:

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 browsers

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}

CDL Drivers
Laborers

{/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.


Report Offensive Message For Removal


Response Number 1
Name: Michael J (by mjdamato)
Date: July 24, 2005 at 18:59:22 Pacific
Reply: (edit)

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:

CDL Drivers

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.


Report Offensive Follow Up For Removal

Response Number 2
Name: Michael J (by mjdamato)
Date: July 24, 2005 at 19:01:01 Pacific
Reply: (edit)

Let's try again replacing the < & > with brackets:

[a href="#" ONCLICK="winopen();return false;"]CDL Drivers[/a]


Report Offensive Follow Up For Removal

Response Number 3
Name: BigShow
Date: July 24, 2005 at 19:21:20 Pacific
Reply: (edit)

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.


Report Offensive Follow Up For Removal

Response Number 4
Name: randy1959
Date: July 24, 2005 at 20:38:19 Pacific
Reply: (edit)

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]



Report Offensive Follow Up For Removal

Response Number 5
Name: Michael J (by mjdamato)
Date: July 25, 2005 at 06:37:44 Pacific
Reply: (edit)

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


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: java script pop up

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge