473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

targeting frames with javascript

Have pity on me.. i have been doing html, css, javascript squarely over 2 years... and am now doing a family project.. in my project i have decided to use a context menu script, its a menu that pretty much allows for when you right click on a page it shows you different links that the standard right click menu, link here:
http://www.dynamicdrive.com/dynamici...ontextmenu.htm
What it does exactly is opens a new window with the link that you have chosen, on the link that i have given above the demo is in the page, right click anywehre, and you'll see... now.. like is said it opens with a right click,... the problem that i am having is that when a window opens...it opens in a new window... i want it to open in one of my frames, here is the code snippet: (thats the original that i didnt change )


Code:
[HTML]<div id="ie5menu" class="skin0" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" display:none>
<div class="menuitems" href="http://www.google.com">google</div>
<div class="menuitems" url="http://dynamicdrive.com/new.htm" target="newwin">What's New?</div>
<div class="menuitems" url="http://dynamicdrive.com/hot.htm">What's Hot?</div>
<div class="menuitems" url="http://wsabstract.com/cgi-bin/Ultimate.cgi">Message Forum</div>
<div class="menuitems" url="http://dynamicdrive.com/faqs.htm">FAQs</div>
<div class="menuitems" url="http://dynamicdrive.com/submitscript.htm">Submit</div>
<hr>
<div class="menuitems" url="mailto:dynamicdrive@yahoo.com">Email Us</div>
</div>
[/HTML](main is the name of one of the frames that i am using)
i change the

Code:
[HTML]<div class="menuitems url="http://www.google.com">google</div>[/HTML](which works by the way) to
[HTML]<div class="menuitems url="http://www.google.com" target="main">google</div>[/HTML] (main is a legit name of one of my frames) however that doesnt seem to work the window still launches in a new window. i have even tried to delete the whole <div> </div> and replace it all with [HTML]<a href="http://www.google.com" target="main">gogle</a>[/HTML] but that just breaks the menu altogether,...

one person on a html forum told me that the problem is not in my html code... but in the operating javascript... the menu is not running an external javascript code, however there is an internal javascript functions, but i dont know how to change it to open in a frame, i am posting the body of the document below:



Code:
[HTML]<div id="ie5menu" class="skin0" onMouseover="highlightie5(event)" onMouseout="lowlightie5(event)" onClick="jumptoie5(event)" display:none>
<div class="menuitems" url="http://dynamicdrive.com">Dynamicdrive.com</div>
<div class="menuitems" url="http://dynamicdrive.com/new.htm" target="newwin">What's New?</div>
<div class="menuitems" url="http://dynamicdrive.com/hot.htm">What's Hot?</div>
<div class="menuitems" url="http://wsabstract.com/cgi-bin/Ultimate.cgi">Message Forum</div>
<div class="menuitems" url="http://dynamicdrive.com/faqs.htm">FAQs</div>
<div class="menuitems" url="http://dynamicdrive.com/submitscript.htm">Submit</div>
<hr>
<div class="menuitems" url="mailto:dynamicdrive@yahoo.com">Email Us</div>
</div>
[/HTML]
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript1.2">
  2.  
  3. //set this variable to 1 if you wish the URLs of the highlighted menu to be displayed in the status bar
  4. var display_url=0
  5.  
  6. var ie5=document.all&&document.getElementById
  7. var ns6=document.getElementById&&!document.all
  8. if (ie5||ns6)
  9. var menuobj=document.getElementById("ie5menu")
  10.  
  11. function showmenuie5(e){
  12. //Find out how close the mouse is to the corner of the window
  13. var rightedge=ie5? document.body.clientWidth-event.clientX : window.innerWidth-e.clientX
  14. var bottomedge=ie5? document.body.clientHeight-event.clientY : window.innerHeight-e.clientY
  15.  
  16. //if the horizontal distance isn't enough to accomodate the width of the context menu
  17. if (rightedge<menuobj.offsetWidth)
  18. //move the horizontal position of the menu to the left by it's width
  19. menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth
  20. else
  21. //position the horizontal position of the menu where the mouse was clicked
  22. menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX
  23.  
  24. //same concept with the vertical position
  25. if (bottomedge<menuobj.offsetHeight)
  26. menuobj.style.top=ie5? document.body.scrollTop+event.clientY-menuobj.offsetHeight : window.pageYOffset+e.clientY-menuobj.offsetHeight
  27. else
  28. menuobj.style.top=ie5? document.body.scrollTop+event.clientY : window.pageYOffset+e.clientY
  29.  
  30. menuobj.style.visibility="visible"
  31. return false
  32. }
  33.  
  34. function hidemenuie5(e){
  35. menuobj.style.visibility="hidden"
  36. }
  37.  
  38. function highlightie5(e){
  39. var firingobj=ie5? event.srcElement : e.target
  40. if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
  41. if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node
  42. firingobj.style.backgroundColor="highlight"
  43. firingobj.style.color="white"
  44. if (display_url==1)
  45. window.status=event.srcElement.url
  46. }
  47. }
  48.  
  49. function lowlightie5(e){
  50. var firingobj=ie5? event.srcElement : e.target
  51. if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
  52. if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode //up one node
  53. firingobj.style.backgroundColor=""
  54. firingobj.style.color="black"
  55. window.status=''
  56. }
  57. }
  58.  
  59. function jumptoie5(e){
  60. var firingobj=ie5? event.srcElement : e.target
  61. if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
  62. if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode
  63. if (firingobj.getAttribute("target"))
  64. window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target"))
  65. else
  66. window.location=firingobj.getAttribute("url")
  67. }
  68. }
  69.  
  70. if (ie5||ns6){
  71. menuobj.style.display=''
  72. document.oncontextmenu=showmenuie5
  73. document.onclick=hidemenuie5
  74. }
  75.  
  76. </script> 
  77.  
  78.  
i've figured out its this part


Expand|Select|Wrap|Line Numbers
  1. function jumptoie5(e){
  2. var firingobj=ie5? event.srcElement : e.target
  3. if (firingobj.className=="menuitems"||ns6&&firingobj.parentNode.className=="menuitems"){
  4. if (ns6&&firingobj.parentNode.className=="menuitems") firingobj=firingobj.parentNode
  5. if (firingobj.getAttribute("target"))
  6. window.open(firingobj.getAttribute("url"),firingobj.getAttribute("target"))
  7. else
  8. window.location=firingobj.getAttribute("url")
  9. }
  10. }
  11.  
  12.  
i've changed the last line (window.location=firingobj.getAttribute("url")
to the following:

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("kirupa").src=firingobj.getAttribute("url");
  2. kirupa.location=firingobj.getAttribute("url")
  3. Kirupa.document.location=firingobj.getAttribute("url")
  4. document.frames[kirupa].location=firingobj.getAttribute("url")
  5. document.frames["kirupa"].location=firingobj.getAttribute("url")
  6.  
...nothing works.. help?
Aug 15 '07 #1
3 2371
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

Your link is broken. See how to access frames here.
Aug 16 '07 #2
yea that dont work... tried all that, im doing javascript int.. meaning i need help changing this line

parent.frames['kirupa'].location.href=firingobj.getAttribute("url");
Aug 16 '07 #3
acoder
16,027 Expert Mod 8TB
Try
Expand|Select|Wrap|Line Numbers
  1. parent.kirupa.location.href=firingobj.getAttribute("url");
PS. changed thread title to remove "HELP?!".
Aug 17 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: elad | last post by:
Hi The Menu doesn't work properly when I have 2 frame and the Menu popup frame=document target frame, when I choose item in the menu the doc opened and the menu get stuck. Here is the code...
14
by: TrvlOrm | last post by:
OK. After much playing around, I managed to get my frame page this far.. see code below. BUT...there are still errors with it, and what I would like to have happened is this: 1) On the Left...
7
by: David Hayes | last post by:
I tried finding an answer on http://www.quirksmode.org/ without success. I am attempting a complicated Frames structure. I have made it work in IE, but not Netscape. I begin with three...
3
by: qwerty | last post by:
I´m new to ASP.Net. My workmate has some experience with it. He claimed that in ASP.Net working with frames is much simpler than it was ASP. I asked explanation but he couldn't give me such. (a...
1
by: Frances Valdes | last post by:
I have been struggling with this and would be really grateful if anyone could help. I have a page with 2 frames. I would like to use the page load event on the left hand page to use a variable...
10
by: Richard Lionheart | last post by:
Hi All, I'm trying to put together a model presentation system consisting of a: -- "toolbar" row, -- three columns for topics, subtopics and a workarea (content) -- a "footer" row. The...
10
by: steve | last post by:
Hi All, My site has two frames, one with a menu system, one with the selected results. I can select a menu item and get the other frame to reflect that selection. But I want to select 'log...
0
by: bharathreddy | last post by:
Vs 2008 is the MS latest IDE for developing Windows, Web, Smart Device Applications. It comes along with .NET Framework 3.5, C# 3.0, LINQ, ASP.NET AJAX and VSTO . Now with the power of VS 2008 we can...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.