Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Needs Javascript Help

Status
Not open for further replies.

cottonchipper

Programmer
Jan 28, 2006
5
0
0
US
Having no experience with Javascript, I'm trying to learn how to open a new window with specific attributes by clicking on an image. I don't have a clue what I'm doing wrong, unless I need to include a SCRIPT command in there somewhere.

Here's the page where the problem is located:


I'm trying to make the upper right hand image clickable to open a file called and have the ability to use the different window options for size, position, etc.

Any help you can provide will be VERY appreciated!
 
Your onclick is all wrong. You've got an extra [blue]onClick[/blue], you don't need the [blue]javascript:[/blue] (as it's an onclick event), you're calling [blue]window.open([/blue] but not closing the bracket, and you call the method with a trailing comma but no extra parameters.

You should take a look at MSDN reference for window.open or Moz / Gecko reference for window.open.

Code:
<img
 [blue]onclick='[purple]onClick=javascript:window.open("[URL unfurl="true"]http://www.markcotton.com/mosaic/pacifico.html",[/URL][/purple]'[/blue]
 alt="&quot;Pacifico&quot; by Mark Cotton"
 src="[URL unfurl="true"]http://www.markcotton.com/mosaic/th_pacifico.jpg"[/URL]
 style="border: 0px solid ; width: 50px; height: 50px;">

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
I think I've fixed those errors, but I've apparently still got something wrong.

Code:
<img
 onclick='window.open("[URL unfurl="true"]http://www.markcotton.com/mosaic/pacifico.html","width=350,height=500,toolbar=no")'[/URL]
 alt="&quot;Pacifico&quot; by Mark Cotton"
 src="[URL unfurl="true"]http://www.markcotton.com/mosaic/th_pacifico.jpg"[/URL]
 style="border: 0px solid ; width: 50px; height: 50px;">
 
Code:
window.open(sUrl, sName, sFeatures)

Although it seems that each item is optional, IE requires that you specify sName before you can specify sFeatures.
Code:
<img
 onclick='window.open("[URL unfurl="true"]http://www.markcotton.com/mosaic/pacifico.html",[/URL][red] "Mark Cotton",[/red] "width=350,height=500,toolbar=no")'
 alt="&quot;Pacifico&quot; by Mark Cotton"
 src="[URL unfurl="true"]http://www.markcotton.com/mosaic/th_pacifico.jpg"[/URL]
 style="border: 0px solid ; width: 50px; height: 50px;">

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
Still have a problem somewhere. Forgive my ignorance, but do I need anything in the page header to make this work?

Code:
<img
 onclick='window.open( "[URL unfurl="true"]http://www.markcotton.com/mosaic/pacifico.html"[/URL] , "Mark Cotton" , "width=350,height=500 , toolbar=no" )'
 alt="&quot;Pacifico&quot; by Mark Cotton"
 src="[URL unfurl="true"]http://www.markcotton.com/mosaic/th_pacifico.jpg"[/URL]
 style="border: 0px solid ; width: 50px; height: 50px;">
 
Wow... I've just viewed the source to your page. Talk about using a sledgehammer to crack a walnut. No... in fact, it's worse - it's using an axe to remove a fly from your nose.

I've never seen such a bad mis-use of tables to create whitespace - it's shocking.

You really, really, really, should head over to the HTML / CSS forum (forum215) and ask about using CSS to get rid of those tables. There's just no need for them.

You might also want to consider putting an anchor element around the image, so that those with JavaScript disabled can still view the pages. Those with JS enabled can still have the popup without any problem at all.

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Marcus....That did it! Thank you!

Dan.....Mea culpa, mea culpa, mea maxima culpa. Thank you for the suggestion. I might just actually learn something out of this little project.
 
One more question regarding the use of a table....

The primary reason for the use of the table is that the number of thumbnail images used will continue to grow, and this allows me to easily drop them into the empty boxes.

My use of some white jpg's is to help center the group of images until such time as the area around them fills in.

Would I still be better off using CSS??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top