Jump to content

JumpMenu to anchor in iFrame on different page??


eTard
 Share

Recommended Posts

Okay - I am working on a scenario where I have a drop down JumpMenu. Within that drop down are links that I want to link to certain anchors in an iFrame on different page than what the drop down is on. So, when you select your option from the drop down JumpMenu, it rolls-over too a new page and said new page has an iFrame in it and you link to a specific anchor in that iFrame file.So, I can get the drop down to roll-over to the new page with the iFrame in it just fine, but I cannot get the JumpMenu to find the anchor in that iFrame I want it to.

<SELECT name="menu1" onChange="MM_jumpMenu('parent',this,0)"><option value="#" selected>Select Your State</option><option value="no_listing.html">Alabama </option><option value="listing2.html#arizona" target="iframe">Arizona </option><option value="no_listing.html">Arkansas </option></SELECT>

see the Arizona option. As it is coded, it rolls-over to listing2.html (which has an iframe on it called "iframe"), but does not find the #Arizona anchor within the iFrame content on that page.I understand the error, but not sure how to correct it. The error is that I am telling the jump menu to link to an #anchor on listing2.html, but the anchor is not actually on listing2.html, but it is in the file that the iFrame calls on listing2.html.So, how do I get the drop down JumpMenu to link to an anchor within a file in an iFrame on another page that the JumpMenu is not on???I can solve it with Frames - and it is done in the onChange - but i want to use a cleaner iFrame.Naturally, this takes 3 pages. The page with the JumpMenu on it, the page that contains the iFrame, the file that is the content of the iFrame. I need tp get page 1 to link to an anchor in page 3 called by page 2...

Link to comment
Share on other sites

You might consider using javascript to change the src of your iframe in your MM_jumpMenu function.For example:

function MM_jumpMenu(obj){  // get the value of the select menu.  var value = obj.value;  // get the index of where the "#" appears in the value  var idx = value.indexOf("#");    // if there is a "#"...  if(idx > 0)  {	// get the target from the value using substr.	var len = value.length;	var targ = value.substr(idx, len);	// change the src of the iframe to reflect the target.	var myIFrame = document.getElementById('iframeid');	myIFrame.src = "test.html" + targ;  }  // do whatever else your MM_jumpMenu function needed to do}

Link to comment
Share on other sites

hmm...Kind of follow you.here is what is in the head:

<script type="text/JavaScript"><!--function MM_jumpMenu(targ,selObj,restore){ //v3.0  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");  if (restore) selObj.selectedIndex=0;}//--></script>

are you saying put your fucntions before the function above? like this

<script type="text/JavaScript"><!--// get the value of the select menu.  var value = obj.value;  // get the index of where the "#" appears in the value  var idx = value.indexOf("#");    // if there is a "#"...  if(idx > 0)  {	// get the target from the value using substr.	var len = value.length;	var targ = value.substr(idx, len);	// change the src of the iframe to reflect the target.	var myIFrame = document.getElementById('iframeid');	myIFrame.src = "test.html" + targ;  }function MM_jumpMenu(targ,selObj,restore){ //v3.0  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");  if (restore) selObj.selectedIndex=0;}//--></script>

if I got this correct, what elements in the script do I change? My 3 files are: index.html holds this script and JumpMenu, llisting2.html is the page with the iFrame in it and the iFrame itself (named iframe) is a file called listings.html with the actual states like Arizone...

Link to comment
Share on other sites

Hmm. It seems I read your post wrong. I missed the part about listing2.html being a separate page and the page with the JumpMenu not having any frames - must need more coffee...The code I wrote could only work if the menu was in the same page as the iframe. Perhaps you could create a function that fires when listing2.html loads that can find the "#xxxxxx" value in the URL and then run the little script to get that value and then change the src of the iframe.I looked at "location.hash" but it appears that IE doesn't like it too much.This code worked well for me in Firefox but IE threw up all sorts of security errors...

<script type="text/javscript">function init(){  var hash = location.hash;  var iframe = document.getElementById("myIframe");  iframe.src += hash;}window.onload = init;</script>

Try looking around at how to get values from query strings: Google Search

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...