View Full Version : Opening links in new window
Decker
03-10-2005, 03:37 AM
I want to open a link in a new window with a custom size and w/o any toolbars and such.
Am I correct in that I have to use JavaScript for that? I've successfully implemented the script I need into a submit button, but I want to do the same with a graphic button, i.e. a small TD background image with a text in the cell acting as the link.
So far I've got this:
<TD background="path/image.gif">
<a href="" title="Opens new window" onClick="window.open('http://www.url.address','Window name','width=820,height=600','menubar=no','directo ries=no','status=no')"> Link text</a>
</TD>
This works fine in Firefox. But I guess IE gets confused about the empty href value because nothing happens when I press the link.
Help, please.
Phait
03-10-2005, 03:45 AM
Try...
<a href="#" onclick="window.open('yourpage.html','Windowname','width=30 0,top=0,left=0,height=240,scrollbars=0'); return false;">
As for particular window elements to show, there's a list of parameters out there, I don't really KNOW javascript so...
Decker
03-10-2005, 05:07 AM
Weird. The link only works in IE if the only parameter I leave in is the target URL.
Another approach that would eliminate the need for all the stuff I previously asked would be to modify the originating page itself to accommodate my requirements.
So my question is:
How do I set a browser window to hide scroll bars, tool bars and such when I open the page manually? I managed to set the size and position with the following script, which I then executed using <body onLoad="JavaScript:windowMod()")>
<script language="JavaScript">
function windowMod()
{
window.resizeTo(300,200);window.moveTo(10,10);
}
</script>
So, what's the window.xxx command for setting the toolbar=no, scrollbars=no etc?
Night Hacker
03-10-2005, 10:46 PM
This is how I did it...
First I have some javascript early on my webpage...
<script LANGUAGE="javascript">
function Screen01() {
X=window.open("screen1.html","X","toolbar=no,scrollbars=yes,directories=no,resizable =1,menubar=no,width=700,height=550")
}
Later in my page I have a small thumbnail image and a link to the above java that opens up a small window with the image etc...
<a href="javascript:Screen01()"><img src="thumbnail.jpg" border="0"></a>
Of course, you need a scree1.html (or whatever you call it) with your image code etc...
This is mine (trimmed down actually)...
<html>
<head>
<title>Screen1</title>
</head>
<body bgcolor="#E99D49">
<center>
<img src="dev001.jpg" border="3"><br>
<a href="javascript:window.close()">Close Window</a>
</center>
</body>
</html>
The close window part isn't really needed, but I include it anyhow, just in case.
I'm curious, if I would have multiple of those clickable thumbnails on one page and I use the same javascript code for it but different targetimages, is there a way to centralize the JavaScript code used for the pop-up?
Btw, I use this code for my thumbnails.
<a onclick="window.open('image-url,'View picture',
'width=800,height=600,scrollbars=yes,toolbar=no,st atus=no,resizable=no,location=no'); return false" href="image-url" target="_blank"><img src="thumbnail.jpg" border="0" width="80" height="60" alt="" /></a>
This seems to work in Firefox and IE 6.0, plus the official validator approves it.
vBulletin® v3.8.0 Release Candidate 1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.