December 7th, 2002, 10:29 AM
|
#1 (permalink)
| | Kawaru wa yo!
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 16,132
| [HTML] onClick link into new window?
Okay, here's what I have right now...
onClick="window.location.href='content.htm'"
That of course opens the link in the same window. What I would like it so open the link in a new window altogether, like what target="_blank" does. Can someone help me out with this?
-Whir
Okay, here is the entire piece of code so as to be less confusing.
<td width="140"
onMouseOver="do.something"
onMouseOut="do.something.else"
onClick="window.location.href='content.htm'">
Link Text</td>
What this does is changes a property of the cell when the mouse moves over and off of the cell (like when you're browsing the main category listing here and the background changes color).
window.location.href opens the specified page on the current page. If you're in a frame, it opens it in that frame. If you change window to the name of another frame, or an inline frame, it will open the page there. What I need is for the page to open in a completely new browser window. It has to go in the onClick part of the script.
Last edited by Whir : December 7th, 2002 at 12:54 PM.
|
| |
December 7th, 2002, 11:23 AM
|
#2 (permalink)
| | Senior Member
Join Date: Oct 2001
Posts: 899
|
Okay I found out how to do it with a form. Not sure if this is what you need though:
<FORM>
<INPUT type="button" value="Click" onClick="window.open('content.html','windowname',' width=400,height=200')">
</FORM>
Last edited by Gutter Ball : December 7th, 2002 at 11:30 AM.
|
| |
December 7th, 2002, 12:46 PM
|
#3 (permalink)
| | Member
Join Date: Nov 2001 Location: Bloomington IN
Posts: 219
|
Put this in the head section:
<script language="JavaScript">
<!--
function openwindow()
{
window.open('file.html', 'newwindow', 'width=xxx,height=xxx,scrollbars=yes');
}
//-->
</script>
Then do the link this way:
<a href="javascript:openwindow()">Somewhere</a>
That should do the trick. |
| |
December 7th, 2002, 12:50 PM
|
#4 (permalink)
| | Kawaru wa yo!
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 16,132
|
I can't. It has to work with the onClick function.
Thanks for the info though.  |
| |
December 7th, 2002, 12:54 PM
|
#5 (permalink)
| | Member
Join Date: Nov 2001 Location: Bloomington IN
Posts: 219
|
<a href onClick="window.open(file.htm','windowname','width =400,height=200')">link</a>
Sorry, didn't read your post well enough  |
| |
December 7th, 2002, 12:58 PM
|
#6 (permalink)
| | Kawaru wa yo!
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 16,132
|
Dude, you rock! Thank you!!
Now do you know how to make it open the new window maximazed all the time, or is that just a browser thing (Mozilla will open full if your last close was full, IE always open in a small window)?
Thanks also Gutterball. I didn't notice your new code up there until after I posted this. Smart people are cool to have around.  |
| |
December 7th, 2002, 01:00 PM
|
#7 (permalink)
| | Member
Join Date: Nov 2001 Location: Bloomington IN
Posts: 219
|
Hmm...that is beyond me. I am sure there is a browser compatibility reference chart for javascript somewhere!
Glad I could partially help! |
| |
December 7th, 2002, 01:13 PM
|
#8 (permalink)
| | Kawaru wa yo!
Join Date: Oct 2001 Location: Kingsford, MI
Posts: 16,132
|
Cool, thanks again guys!
(maybe IE folk will just have to live with it, eh?  ) |
| |
December 7th, 2002, 01:44 PM
|
#9 (permalink)
| | Senior Member
Join Date: Oct 2001
Posts: 899
|  Whoa, there are a few different ways to do it! If you figure out how to make IE open in a full window instead of a small one, post it! I don't know why it's so random  Mine usually open in a small window, but the ones at work open in a full window...I don't get it  |
| |
June 27th, 2008, 03:15 PM
|
#10 (permalink)
| | Junior Member
Join Date: Jun 2008
Posts: 1
|
You can control the position and size that the window opens using this:
<script>
window.resizeTo(800, 600);
window.moveTo(200,100);
</script>
which you put in the head of the html document, but I don't know how you always make it a full window for any size screen. |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |