PDA

View Full Version : need help finding a script that will open a new window


Sparkysgirl
04-07-2004, 02:51 PM
I've found several scripts that will open new windows with the press of a button or a check box. What I am looking for is a script that will open a new window by just clicking on the link to the page. I have pages with several links on them to poems, tracts, etc. and think it would be easier if it just opened a new window that could be closed when they are done with it, as opposed to having to click a back button. (How's that for a run-on sentence?) This way the "menu" page is always available.

Paul Jr
04-07-2004, 02:54 PM
http://www.webdevfaqs.com/javascript.php#popup

'Course, it'd be better to make a function for it:

<script type="text/javascript">
//<![CDATA[
function newWin(url, w, h) {
window.open(url, "", "width="+w+", height="+h+", scrollbars, resizable");
}
//]]>
</script>

Then for a link it'd be like:
<a href="page.html" onclick="newWin(this.href, '500', '500'); return false;">Linkage</a>

karinne
04-07-2004, 02:59 PM
here's what i use

<a href="page.html" onclick="MyWindow=window.open('page.html',
'MyWindow','toolbar=no,location=no,
directories=no,status=no,menubar=no,
scrollbars=no,resizable=no,width=295,
height=400'); return false;" target="_blank">page</a>

*edit: i knew i was forgetting something ;)

Sparkysgirl
04-07-2004, 03:00 PM
Thanks so much PaulJr! That is exactly what I was looking for. (I used your function instead of the link) It works perfect! :D

agent002
04-07-2004, 03:00 PM
almost perfect, Karinne... just add target="_blank" to the <a> tag so non-JavaScript users will get the page in a new window :)

Joe
04-07-2004, 03:02 PM
you could search the forums for many other veriations of that code ;)