Welcome to WebmasterWorld Guest from 18.208.159.25

Forum Moderators: open

Message Too Old, No Replies

location.href in a new window

     
1:32 am on Dec 9, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 27, 2003
posts:68
votes: 0


Hi,
anybody could help me with the following string:
<input type="submit" value="" OnClick="window.location.href='#.htm';">

I want it to open in a new window like blank.
thank u

11:32 am on Dec 9, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


Hi Natko,

window.open looks like the thing for you!

It is of the format:


window.open(URL, title, features)

For example:

window.open('myPage.html','Title','resizable=yes,width=500,height=400, top=10, left=10');

More details here [javascript.about.com], including features use.

HTH

1:31 pm on Dec 9, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 27, 2003
posts:68
votes: 0


thank you;

another confirm ...
I've used:
<script language="JavaScript">
<!-- hide me
function plainWindowF()
{
plain_window =
window.open("form.html","plain","width=470,height=452");
}
// end hide -->
</script>

AND THEN CALL IT WITH:

<input type="submit" value="write to us" class="botun" onClick="plainWindowF();">

INSTEAD OF THIS I CAN WRITE SIMPLY:

<input type="submit" value=" scriveteci " class="button" onClick="window.open('form.html','form','width=470,height=452,left=10,top=163,location=no, menubar=no,status=no,toolbar=no,scrollbars=no,resizable=yes');">

WITHOUT USING THE FUNCTION? RIGHT?
thanks again

2:03 pm on Dec 9, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


Yes - spot on!

You can open the window directly from the onClick without the need for a function.

Although, a function would make your code neater!

Don't forget that if you are using javascript to link to another page, to put the url in an href:

<a href="link.html" onClick="some javascript; return false" title="Some Title">...</a>

This keeps the link search engine friendly and the page accessible. The return false in the onClick tells the browser to ignore the default action (opening the link in the current window) and use the javascript commands instead.

HTH

2:34 pm on Dec 9, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 27, 2003
posts:68
votes: 0


yes, but ... I don't think I'm using a href. I use input as a button and onClick so putting the URL in a href ... is not for this case?!
2:48 pm on Dec 9, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


Ah - sorry, quite right!

Just the onClick="window.open..."

11:08 pm on Dec 9, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 27, 2003
posts:68
votes: 0


I checked the following syntax
<input type="submit" value="write to us" class="button" onClick="window.open('form.html','form');">
on lynx browser and it doesn see it.
Does it mean that crowlers (Google) won't see it or ignore it becouse a href?
11:25 am on Dec 10, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Feb 25, 2002
posts:3185
votes: 0


Yes - SE's at the moment don't follow javascript links, which is why accessiblity principles like including the href (as in my first post above), also help with optimising a site for search engines.

My advice: try not to use buttons and javascript for your links...

11:38 am on Dec 10, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Oct 27, 2003
posts:68
votes: 0


thank you
I think I'll change it with some gifs.
thanks again