Forum Moderators: open

Message Too Old, No Replies

location.href in a new window

         

Natko

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

10+ Year Member



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

BlobFisk

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

WebmasterWorld Senior Member 10+ Year Member



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

Natko

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

10+ Year Member



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

BlobFisk

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

WebmasterWorld Senior Member 10+ Year Member



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

Natko

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

10+ Year Member



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?!

BlobFisk

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

WebmasterWorld Senior Member 10+ Year Member



Ah - sorry, quite right!

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

Natko

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

10+ Year Member



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?

BlobFisk

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

WebmasterWorld Senior Member 10+ Year Member



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...

Natko

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

10+ Year Member



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