Gossamer Forum
Home : General : Internet Technologies :

MM_jumpMenu new, but same window?

Quote Reply
MM_jumpMenu new, but same window?
How would I create a dropdown menu that opens links in another window (e.g. "view_frame")?

Here's a sample script that opens the link to the same window (parent):
<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>

<form name="form1">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="#" selected>Archives</option>
<option value="link.html">link</option></select>
</form>

Staffer Stone changed it to this:
function MM_jumpMenu(selObj,restore){ //v3.0
var url = selObj.options[selObj.selectedIndex].value;
if (url) window.open(url);
if (restore) selObj.selectedIndex=0;
}

And HTML script should be:
<select name="menu1" onChange="MM_jumpMenu(this,0)">
<option></option>
<option value="link.html">link</option>
</select>

This works for new window for each link that is selected, but I want all of my links to go the same place.

Also, how do I create a selection that does NOT open a link. When I click on the selection that has a # sign it opens up the parent page as a new window.
Quote Reply
Re: [groversd] MM_jumpMenu new, but same window? In reply to
Use window.location = url instead of window.open(url)

TheStone

B.
Quote Reply
Re: [TheStone] MM_jumpMenu new, but same window? In reply to
That didn't work. It opened the URL in the same window (the parent). I want it to open a whole new window (which I will call "view_frame"> and then each of the other links from the drop-down menu to open in that new window ("view_frame").
Quote Reply
Re: [groversd] MM_jumpMenu new, but same window? In reply to
Oops... You should call rs subroutine which I gave you like:

...
if (url) rs('view_frame', url);
...

B.
Quote Reply
Re: [TheStone] MM_jumpMenu new, but same window? In reply to
I'm sorry, but I don't know where to place:
if (url) rs('view_frame', url);

Do I replace this line:
if (url) window.open(url);

What about this command:
window.location = url

Do I forget about it?
Quote Reply
Re: [groversd] MM_jumpMenu new, but same window? In reply to
Replace MM_jumpMenu subroutine with the script below:

function MM_jumpMenu(selObj,restore){ //v3.0
var url = selObj.options[selObj.selectedIndex].value;
if (url) {
remote = window.open(url, 'view_frame');
if (remote != null) {
if (remote.opener == null)
remote.opener = self;
}
}
if (restore) selObj.selectedIndex=0;
}

B.

Last edited by:

TheStone: Jun 19, 2002, 3:39 PM
Quote Reply
Re: [TheStone] MM_jumpMenu new, but same window? In reply to
Thank you SO much, Mr. Stone!!! Sly

How come you're so smart?
Quote Reply
Re: [groversd] MM_jumpMenu new, but same window? In reply to
change this
<form name="form1">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option value="#" selected>Archives</option>
<option value="link.html">link</option></select>
</form>
to this
<form name="form1">
<select name="menu1" onChange="MM_jumpMenu('self',this,0)">
<option value="#" selected>Archives</option>
<option value="link.html">link</option></select>
</form>

you can use the window references without the "_"
so _self becomes self and so on.

worked for meSly
In Reply To:
Quote Reply
Re: [groversd] MM_jumpMenu new, but same window? In reply to
Hi, I'm using function MM_jumpMenu(targ,selObj,restore) In my form <form name="Select Doulton ">
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">
<option selected>Buy Doulton water filter</option>
<option value....... . . </option></select>
</form>
HTML validatorg gives me error, Error: required attribute ACTION not specified Could you help me, please?
Quote Reply
Re: [TheStone] MM_jumpMenu new, but same window? In reply to
hi Mr.Stone

i had the same problem before i read your solution thanks for this,but i have another problem about this script.

i want some of the urls open in same window and some others in a new window in same pull-down menu.

what should i do?
Quote Reply
Re: [venomssin] MM_jumpMenu new, but same window? In reply to
guys can anyone help with this one ! i want that the target of this script when the second item in the menu would be selected will open in the mainframe and not in parent or self
// default behavior: the filename does not exist
return false;
}

$dh = opendir($dir);
while($file = readdir($dh))
{
if ($file != "." && $file != ".." && is_dir($file))
{$dname[] = $file;
sort($dname);
reset ($dname);
}
}

print "<script language=\"JavaScript\">";
print "function MM_jumpMenu(targ,selObj,restore){eval(targ+\".location='\"+selObj.options[selObj.selectedIndex].value+\"'\");";
print " if (restore) selObj.selectedIndex=0;}";
print "</script>";
print "<form name=\"form1\">";
print "<select name=\"menu1\" onChange=\"MM_jumpMenu('parent',this,0)\">";
print "<option value=\"#\">Go to...</option><br>\n";
$u=0;
foreach($dname as $key=>$val)
{ if($dname[$u])
{ print "<option value=\"index.php?imgdir=$dname[$u]\">$dname[$u]</option>\n";
$u++;
}
}
print "</select>";

if ($imgdir =="")
{$imgdir = $dname[0];
}
$dimg = opendir($imgdir);
while($imgfile = readdir($dimg))
{
if( (substr($imgfile,-3)=="gif") || (substr($imgfile,-3)=="jpg") || (substr($imgfile,-3)=="JPG") || (substr($imgfile,-3)=="GIF") )
{
$a_img[count($a_img)] = $imgfile;
sort($a_img);
reset ($a_img);
}
}

print "<h2>$imgdir</h2>";
$totimg = count($a_img); // total images number
$totxpage = $col*$maxrow; // images x page
$totpages = ($totimg%$totxpage==0)?((int)$totimg/$totxpage):((int)($totimg/$totxpage)+1); // number of total pages
if($totimg == false)
print "<br><font size=2 face=verdana>No Images available in your \"IMAGES\" directory yet!!</font><br>";
else
{

print "</form>";

Last edited by:

Mou7a: Aug 19, 2004, 10:46 AM
Quote Reply
Re: [Mou7a] MM_jumpMenu new, but same window? In reply to
i know Cool i know Cool but im not so idiot lol Laugh
for anothers people (like me Blush ) who wil get the same question
just replace parent bu self in
form name=\"form1\">";
"<select name=\"menu1\" onChange=\"MM_jumpMenu('parent',this,0)\">";
Quote Reply
Re: [TheStone] MM_jumpMenu new, but same window? In reply to
In Reply To:
Replace MM_jumpMenu subroutine with the script below:

function MM_jumpMenu(selObj,restore){ //v3.0
var url = selObj.options[selObj.selectedIndex].value;
if (url) {
remote = window.open(url, 'view_frame');
if (remote != null) {
if (remote.opener == null)
remote.opener = self;
}
}
if (restore) selObj.selectedIndex=0;
} ****** This Scrit Run, but how is possible to use it in frames? I Explain: If I have 3 frames: 1) Top frame with logo of the site; 2) Lateral left frame with the jump-menu; 3) The home page central frame; How can I show the lins choosen with the jump menu in the Home page central without refresh all the site? Many thanks in advance ALDO - ITALY
Quote Reply
Re: [TheStone] MM_jumpMenu new, but same window? In reply to
Is it possible to modify this script to have the menu display box display the selected item in the pull-down list, instead of defaulting to the top of the list after a selection is made? Thanks for your help.