Current location: Hot Scripts Forums » General Web Coding » JavaScript » Targeting links using javascript


Targeting links using javascript

Reply
  #1 (permalink)  
Old 06-30-03, 04:05 PM
Greg's Avatar
Greg Greg is offline
iNET Graphics Guru
 
Join Date: May 2003
Location: Kansas City
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Question Targeting links using javascript

I have an iFrame that contains a listing of records from a database. Instead of making the text in each row a link (using a link tag), I am using javascript to make the whole row a link. So, when you double-click the row it'll open a particular link.

----------------
<tr bgcolor="CCCFD6"
onmouseover="this.style.backgroundColor='#DCDEF1'; this.style.cursor = 'hand';"
onmouseout="this.style.backgroundColor='#CCCFD6';"
ondblclick="location.href='#';">
----------------

Right now all the links open in the iFrame, when I want them to open in the main window. I have done a lot of research and I can't find the right code to make the links not open in the iFrame. If I used regular <a> tag it would be simple to set the target="_top". What I have tried is: location.target='_top';, but it doesn't work.

Any input would be a great help... thanks.
__________________
Greg Pabst
HotScripts.com Graphics Guru
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 06-30-03, 04:20 PM
Ryan's Avatar
Ryan Ryan is offline
Coding Addict
 
Join Date: May 2003
Location: Virginia
Posts: 391
Thanks: 0
Thanked 8 Times in 3 Posts
As you may know, when you use an iFrame, it's a page that's nested into another page. So, when you say, "_top" it's going to do it in the iFrame. If I understood you correctly, then you want a link that is clicked in the iFrame to open in the main page. When you add the link, try putting the actual address of the page. I'm not a JavaScript expert so I could be entirely wrong, but from what I understand this should work OK.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 06-30-03, 04:26 PM
Greg's Avatar
Greg Greg is offline
iNET Graphics Guru
 
Join Date: May 2003
Location: Kansas City
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Actually a link in an iFrame with target set to "_top" will break out and open in the main window. I just don't know the javascript code to set the link target.
__________________
Greg Pabst
HotScripts.com Graphics Guru
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 06-30-03, 05:01 PM
Ryan's Avatar
Ryan Ryan is offline
Coding Addict
 
Join Date: May 2003
Location: Virginia
Posts: 391
Thanks: 0
Thanked 8 Times in 3 Posts
Ahh, I thought it would stay in the same frame. I guess it's been longer than I thought since I've done JavaScript.
__________________
Ryan Huff
iNET Interactive, LLC

http://www.inetinteractive.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 06-30-03, 05:06 PM
Greg's Avatar
Greg Greg is offline
iNET Graphics Guru
 
Join Date: May 2003
Location: Kansas City
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
:-)

I actually just figured it out. I used: "parent.location.href" instead of "location.href" and that did exactly what I wanted.

Thanks Ryan.. I appreciated your input. :-)
__________________
Greg Pabst
HotScripts.com Graphics Guru
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
php and javascript together? gamextremer2003 PHP 5 11-06-03 03:18 PM
PLZ HLP! Sending Javascript between two frames. Caleb JavaScript 1 09-01-03 01:20 AM
Javascript opens links in new window podman JavaScript 2 08-21-03 02:49 PM
Thousands of dead links Giant Hot Scripts Forum Questions, Suggestions and Feedback 6 08-03-03 11:30 PM
Problem with java links Kingfishsj JavaScript 0 08-01-03 09:09 AM


All times are GMT -5. The time now is 09:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.