PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
Ok I need a bit of help with some code, I'm trying to get a drop down menu to open a page up in a new window like when clicking on the newsletters... but testing it on my machine, it opens the newsletter in the main window & not in a popup
is there anyway to get this to happen?? would be a great help thanks
page im trying to do it on is
http://stnicholas-school.org.uk/head/head.htm
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
you need abit of javascript or vbscript in there
Basically, when option box equals a certain value, which you set in the HTML option box value setting, goto here, etc
And btw, take the right-mouse click event off, if people want to nick your stuff they will, it doesnt protect you against anything
edit: if you wack up the sorce code or sumthing i can write abit of vbscript to do it, but then it will only work in IE browsers Im not good at javascript
[Edited on 05-01-2004 by VisibleMan]
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Online
|
At a guess, find this line:
code: <select name="archives_menu" onChange="MM_jumpMenu('parent',this,0)">
and change 'parent' to '_blank'
Or it might be 'this' wants changing to '_blank'. I'd have to know more about those functions.
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
thing is, paul has javascript in place already - when ya click on the little paper icon it popups with the newsletter. So basically you just piggy back the same code into the option (select) box
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
tried piggybackin it but no joy so far, ill have another go & up it see if it works
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Online
|
No, the MM_jumpMenu function has target as an input, should be very easy to specific a new window in there.
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
aye just messin about with the code now
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
Heres some vbscript and it works
Wack this inside the head tags -
code:
<Script language="vbscript">
Function OpenWin()
Dim strVal
strVal = form1.mnu.options(form1.mnu.selectedindex).value
If strVal <> "#" then
set popupWin = window.open(strVal,"NewsLetter","scrollbars=yes, width=720, height=500")
set popupWin = nothing
End If
End Function
</script>
Then change the selection box bit to this -
code:
<form name="form1">
<select name="mnu" onChange="OpenWin()">
<option value="#" selected>-- Please Choose Newsletter --</option>
<option value="1002.htm">Test1</option>
</select>
'repeat above for others
<input type="button" name="news_view" value="View" onClick="MM_jumpMenuGo('archives_menu','parent',0)">
</form>
Tested it here and it works
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
Rite
got it now to open a popup correctly, but, the parent is also being changed. I've tried sending it to _blank & also completely removing the parent decleration, but doing that stops it working all together...
code: <script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
window.open(eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"),'arch','scrollbars=yes,width=720,height=500');
if (restore) selObj.selectedIndex=0;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_jumpMenuGo(selName,targ,restore){ //v3.0
var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
//-->
</script>
<form name="form1">
<select name="archives_menu" onChange="MM_jumpMenu('parent',this,0)">
<option value="#" selected>-- Please Choose Newsletter --</option>
<option value="1002.htm">October 2002</option>
</select>
<input type="button" name="news_view" value="View" onClick="MM_jumpMenuGo('archives_menu','parent',0)">
</form>
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
ok will give it a try cheers!
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
<select name="archives_menu" onChange="MM_jumpMenu('_new',this,0)">
try that mate, might work although i can just work out javascript lol
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
I've put your function in, works a treat & is much smaller
Cheers
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
just needed to change one thing tho
code: <input type="button" name="news_view" value="View" onClick="MM_jumpMenuGo('archives_menu','parent',0)">
to
code: <input type="button" name="news_view" value="View" onClick="OpenWin()">
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
thing is mate, whats the point in having that button? as soon as you change the option box value it loads up the newsletter so either drop the button or drop the onchange event
Also, note that vbscript isnt that good in other browsers So i would still look for a way to get it to work in javascript. Best bet mate, look it up on javascript.com or something, google etc
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
reet have uploaded the head file
also put a lil thanks in the code
cheers!
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
quote: Originally posted by VisibleMan
thing is mate, whats the point in having that button? as soon as you change the option box value it loads up the newsletter so either drop the button or drop the onchange event
Also, note that vbscript isnt that good in other browsers So i would still look for a way to get it to work in javascript. Best bet mate, look it up on javascript.com or something, google etc
it'l do for now, everyone at work (the school) uses IE6, so as long as it works for them for now, I can work on sorting it out for other browsers soon
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
quote: Originally posted by PaulW
reet have uploaded the head file
also put a lil thanks in the code
cheers!
not a problem mate
|