/    Sign up×
Community /Pin to ProfileBookmark

Onclick for New Window

Hi…

This is my code:

<a href=”hoopshoot2003photos.htm” onClick=”window.open(‘hsphoto1.htm’, ‘perry’,config=’height=530,width=450′)”>Photo 1<br><br><img src=”photos/tnhs1.jpg” border=”0″ width=”120″ height=”90″ target=”top”><br></a>

When I click on the photo, it not only opens a new window but refreshes the original page (hoopshoop2003photos.htm)…what am I doing wrong?

Thanks…

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@hyperliskApr 06.2006 — Try this:
<i>
</i>&lt;a href="javascript: window.open('hsphoto1.htm', 'perry',config='height=530,width=450')"&gt;Photo 1&lt;br&gt;&lt;br&gt;&lt;img src="photos/tnhs1.jpg" border="0" width="120" height="90" target="top"&gt;&lt;br&gt;&lt;/a&gt;
Copy linkTweet thisAlerts:
@Alaska_RaiderauthorApr 06.2006 — Thanks...I did try that, but what it does is open the new window and opens the same window full screen.
Copy linkTweet thisAlerts:
@AltF4Apr 06.2006 — do

<A href="#" onclick="window.open(Yahyahyah); window.replace(Yahyahyah);"><img yahyahyha
Copy linkTweet thisAlerts:
@phpnoviceApr 06.2006 — When I click on the photo, it not only opens a new window but refreshes the original page (hoopshoop2003photos.htm)...what am I doing wrong?[/QUOTE]
If you just want to click an image and have it open a window, then you should do it without a link:

<img src="photos/tnhs1.jpg" border="0" width="120" height="90"

onclick="window.open('hsphoto1.htm', 'perry', 'height=530,width=450'); return false;">
Copy linkTweet thisAlerts:
@Alaska_RaiderauthorApr 06.2006 — Thanks...I tried that as well, but I need an anchor tag <a></a> to make it a hyperlink and it doesn't seem to want to work when I use <a href= img src="photos/tnhs1.jpg" border="0" width="120" height="90"

onclick="window.open('hsphoto1.htm', 'perry', 'height=530,width=450'); return false;"></a>
Copy linkTweet thisAlerts:
@James_GatkaApr 06.2006 — Alaska:

Check your Private Messages.
Copy linkTweet thisAlerts:
@phpnoviceApr 07.2006 — Thanks...I tried that as well, but I need an anchor tag <a></a> to make it a hyperlink[/QUOTE]
But, I said: "If you just want to click an image and have it open a window..." Thus, if you need to link to another page, then you should use a hyperlink. If you are [B][I][U]not[/U][/I][/B] linking to another page, then you should [B][I][U]not[/U][/I][/B] be using a hyperlink. If it is just that you want the mouse cursor to change shape, then add this to your [B]IMG[/B] tag:

style="cursor:pointer;"
Copy linkTweet thisAlerts:
@felgallApr 07.2006 — To have something open in a new window you use:

<a href="nextpage.htm"

onclick="window.open(this.href,'','width=100,height=100");return false"
>open nextpage.htm in a new window</a>

This will still allow the 10% of people with Javascript disabled to access the page or image. Simply substitute your page or image name for nextpage.htm and set the parameters you want to use for the window in the third parameter of the open statement.
Copy linkTweet thisAlerts:
@Alaska_RaiderauthorApr 07.2006 — Thanks Stephan...but this opens up in the same window...what I want is to have it open in a new window...

<a href="photos/hs1.jpg"

onclick="window.open(this.href,'','width=500,height=500");return false"
>Photo 1</a>
Copy linkTweet thisAlerts:
@phpnoviceApr 07.2006 — [code=html]
<a href="photos/hs1.jpg" target="_blank" onclick="
window.open(this.href, this.target, 'width=500,height=500');
return false;">Photo 1</a>
[/code]
×

Success!

Help @Alaska_Raider spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...