473,714 Members | 2,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

targeting frames with javascript

2 New Member
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="hi ghlightie5(even t)" onMouseout="low lightie5(event) " onClick="jumpto ie5(event)" display:none>
<div class="menuitem s" href="http://www.google.com" >google</div>
<div class="menuitem s" url="http://dynamicdrive.co m/new.htm" target="newwin" >What's New?</div>
<div class="menuitem s" url="http://dynamicdrive.co m/hot.htm">What's Hot?</div>
<div class="menuitem s" url="http://wsabstract.com/cgi-bin/Ultimate.cgi">M essage Forum</div>
<div class="menuitem s" url="http://dynamicdrive.co m/faqs.htm">FAQs</div>
<div class="menuitem s" url="http://dynamicdrive.co m/submitscript.ht m">Submit</div>
<hr>
<div class="menuitem s" url="mailto:dyn amicdrive@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="menuitem s url="http://www.google.com" >google</div>[/HTML](which works by the way) to
[HTML]<div class="menuitem s url="http://www.google.com" target="main">g oogle</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">g ogle</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="hi ghlightie5(even t)" onMouseout="low lightie5(event) " onClick="jumpto ie5(event)" display:none>
<div class="menuitem s" url="http://dynamicdrive.co m">Dynamicdrive .com</div>
<div class="menuitem s" url="http://dynamicdrive.co m/new.htm" target="newwin" >What's New?</div>
<div class="menuitem s" url="http://dynamicdrive.co m/hot.htm">What's Hot?</div>
<div class="menuitem s" url="http://wsabstract.com/cgi-bin/Ultimate.cgi">M essage Forum</div>
<div class="menuitem s" url="http://dynamicdrive.co m/faqs.htm">FAQs</div>
<div class="menuitem s" url="http://dynamicdrive.co m/submitscript.ht m">Submit</div>
<hr>
<div class="menuitem s" url="mailto:dyn amicdrive@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.locatio n=firingobj.get Attribute("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 2405
acoder
16,027 Recognized Expert Moderator MVP
Welcome to TSDN!

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

parent.frames['kirupa'].location.href= firingobj.getAt tribute("url");
Aug 16 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
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
5026
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 I'm using: FrameSet ------------------------------------------------------- <html>
14
2162
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 Frame (File LeftEx8_2.html) a series of buttons, which when clicked prompt the user to enter information for background color, text color, link color, title and some text.
7
2327
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 frames, where the two lower ones are within a Frameset within the master Frameset: 1111111111111111111
3
2467
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 button inside a-tag with attribute target isn't anything new relating ASP.Net, its same old HTML). He claimed that you could change another page´s controls´s property´s value from another frame by using this method: ' Page "Bottom"
1
1206
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 to change the page in the right frame. On the left page it would look something like: Private Sub Page_Load etc dim NewHtmlPage as string
10
1798
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 topics column presents three links. When I click on the first link, topic1a, I expect its content to presented in the subtopics
10
2711
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 out' from the menu and remove the menu sytem as well as putting a default welcome page in to 2nd frame. Any ideas will be gratefully received
0
4946
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 target multiple versions of .NET Framework. Installation steps here VS 2008 Multi-Targeting Support: Previously every VisualStudio release supports its own specific version of .NET Framework. That is VS 2002 with .NET 1.0 ...
0
8801
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9015
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
2520
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2110
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.