home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2754
Discussions: 188,382, Posts: 2,243,483, Members: 232,612
Old December 7th, 2002, 10:29 AM   Digg it!   #1 (permalink)
Kawaru wa yo!
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 16,132
Blog Entries: 7
[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.
Whir is offline   Reply With Quote
Old December 7th, 2002, 11:23 AM     #2 (permalink)
Senior Member
 
Gutter Ball's Avatar
 
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.
Gutter Ball is offline   Reply With Quote
Old December 7th, 2002, 12:46 PM     #3 (permalink)
Member
 
tenor_david's Avatar
 
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.

tenor_david is offline   Reply With Quote
Old December 7th, 2002, 12:50 PM     #4 (permalink)
Kawaru wa yo!
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 16,132
Blog Entries: 7
I can't. It has to work with the onClick function.

Thanks for the info though.
Whir is offline   Reply With Quote
Old December 7th, 2002, 12:54 PM     #5 (permalink)
Member
 
tenor_david's Avatar
 
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
tenor_david is offline   Reply With Quote
Old December 7th, 2002, 12:58 PM     #6 (permalink)
Kawaru wa yo!
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 16,132
Blog Entries: 7
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.
Whir is offline   Reply With Quote
Old December 7th, 2002, 01:00 PM     #7 (permalink)
Member
 
tenor_david's Avatar
 
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!
tenor_david is offline   Reply With Quote
Old December 7th, 2002, 01:13 PM     #8 (permalink)
Kawaru wa yo!
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 16,132
Blog Entries: 7
Cool, thanks again guys!

(maybe IE folk will just have to live with it, eh? )
Whir is offline   Reply With Quote
Old December 7th, 2002, 01:44 PM     #9 (permalink)
Senior Member
 
Gutter Ball's Avatar
 
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
Gutter Ball is offline   Reply With Quote
Old June 27th, 2008, 03:15 PM     #10 (permalink)
Junior Member
 
Join Date: Jun 2008
Posts: 1
blah

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.
fdfnjd is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2888)
The United States Debt (20)
Looks like Burris will get his Sena.. (8)
I think I just killed my computer w.. (24)
Upgrading RAM (5)
hp compaq nc6000 problems (138)
Folderchat Weekday thread (440)
Antec 300 bulk purchase? (11)
Help with an Ati Radeon HD 4850 512.. (27)
Recent Discussions
Folderchat Weekday thread (440)
How to increase my ram? (5)
Building a gaming computer advi.. (2)
Help with an Ati Radeon HD 4850.. (27)
CPU wont boot (4)
2nd video card (1)
special characters in quarkxpre.. (3)
Need help removing my front usb.. (2)
Genuine Broadband Connection my.. (14)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 09:25 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28