Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-23-2010, 05:10 PM   PM User | #1
jcdevelopment
Senior Coder

 
jcdevelopment's Avatar
 
Join Date: Oct 2007
Location: Cowboy Nation
Posts: 2,171
Thanks: 173
Thanked 257 Times in 257 Posts
jcdevelopment will become famous soon enoughjcdevelopment will become famous soon enough
Linking a div and making it open in a new window

I am using javascript to make a DIV a link.

What would be the easiest way to set the attribute to "target=_blank?

Code:
onclick="document.location='http://google.com'"
Thanks for any help.
jcdevelopment is offline   Reply With Quote
Old 08-23-2010, 05:23 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
document.location doesn't work that way.


You'd want window.open instead:

Code:
onclick="window.open('http://www.google.com')"
Enjoy.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Users who have thanked Eldarrion for this post:
jcdevelopment (08-23-2010)
Reply

Bookmarks

Tags
attribute, div, linking, _blank

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:21 AM.


Advertisement
Log in to turn off these ads.