Newbie Needs help opening new window with button.

S

StormJr

First I want to apologize, I am very new to this. I want to open a new
window when some one clicks on a certain button. I'm just using it off
my desktop for right now. Here is what I have:

The function:

function newWindow("../New Folder/imageloop.htm") {
if(document.all){
window.open("../New Folder/imageloop.htm", 'fullscreen=yes');
return false;
}
return true;
}

In the Body:

<INPUT TYPE=BUTTON ID="newwindowButton" VALUE="New Window"
ONCLICK="newWindow()" onmouseover="self.status ='Opens Another Window';
return true" onmouseout="self.status=''"><BR>

And the button:

#newwindowButton {
font: 12px verdana,helvetica,arial;
color : #FFFFFF;
border-color: #3333FF;
background-color : #3333AA;
font-weight: bold;
padding-left: 0;
padding-right: 0;
}

Thanks in advance!
 
M

Mick White

StormJr said:
First I want to apologize, I am very new to this. I want to open a new
window when some one clicks on a certain button.
[...]

<INPUT TYPE=BUTTON ID="newwindowButton" VALUE="New Window"
ONCLICK="newWindow()" onmouseover="self.status ='Opens Another Window';
return true" onmouseout="self.status=''"><BR>
[...]
How about

<INPUT TYPE="BUTTON" VALUE="New Window"
ONCLICK="if(!W)(W=window.open('yourURLHere');" >

?
Mick
 
E

Evertjan.

StormJr wrote on 29 mei 2005 in comp.lang.javascript:
First I want to apologize, I am very new to this.

Yes you should. Being new is a mistake, all of us have never been new at
this, but where expert from the baby years.
I want to open a new
window when some one clicks on a certain button. I'm just using it off
my desktop for right now. Here is what I have:

The function:

function newWindow("../New Folder/imageloop.htm") {

The parameter of a function definition should be a variable, not a string
if(document.all){

window.open works for all more or less current browsers,
no need to test for document.all
window.open("../New Folder/imageloop.htm", 'fullscreen=yes');

You need an extra middle argument, that can be empty

fullscreen is dangerous, as it will anger the user, if you don't show an
exit from that window. available alt-F4 is unknown to many.
return false;

The false and true have no purpose here
}
return true;
}

In the Body:

<INPUT TYPE=BUTTON ID="newwindowButton" VALUE="New Window"

preferably use classes in css styles

Try this:

<style>
..newwindowButton {
font: 12px verdana,helvetica,arial;
color : #FFFFFF;
border-color: #3333FF;
background-color : #3333AA;
font-weight: bold;
padding-left: 0;
padding-right: 0;
}
</style>


<button
onclick=
'window.open("../New Folder/imageloop.htm","","fullscreen=yes")'
class='newwindowButton'>
New Window
</button>
 
R

Richard Cornford

Evertjan. said:
StormJr wrote on 29 mei 2005 in comp.lang.javascript:

window.open works for all more or less current browsers,
no need to test for document.all
<snip>

Embedded browser still have a tendency not to support window.open. The -
document.all - test is a nonsense because it has nothing to do with
window opening (it is, for example, true on embedded Netfront 4, which
has no - window.open - method). The test that makes sense, because it
has a direct and obvious one-to-one relationship with the browsers
support for a - window.open - method, is:-

if(window.open){
... // window opening code and verification of the outcome.
}

Richard.
 
D

DU

Evertjan. said:
StormJr wrote on 29 mei 2005 in comp.lang.javascript:

[snipped]
The function:

function newWindow("../New Folder/imageloop.htm") {


The parameter of a function definition should be a variable, not a string

I believe a function parameter can be a string or a value (integer,
boolean, litteral) but it is best to use a local variable.

[snipped]
fullscreen is dangerous, as it will anger the user, if you don't show an
exit from that window. available alt-F4 is unknown to many.

Agreed. Also and more precisely on this issue:

http://developer-test.mozilla.org/d...ow_Reference:window.open()#Note_on_fullscreen

preferably use classes in css styles

It is not justified to use classes if the style info is to be applied on
a single element and document-unique element only. In such case, it's
much more logical to use id and more efficient/performance-wise to use
only the id.

Try this:

<style>

<style type="text/css">

type is required attribute.
.newwindowButton {
font: 12px verdana,helvetica,arial;
color : #FFFFFF;
border-color: #3333FF;
background-color : #3333AA;
font-weight: bold;
padding-left: 0;
padding-right: 0;

padding-left and padding-right on HTML buttons is not implemented the
same way in current modern browsers (MSIE 6, Mozilla 1.x, Firefox 1.x,
Opera 8, Safari 1.2+).

DU
 
S

StormJr

So when someone says:

window.open (URL)...

what do I put in the URL part? I saw this on a post that I searched
for.

function newWindow(URL) {
if(document.all){
window.open(URL, New Window, 'fullscreen=yes');
return false;
}
return true;
}
 
E

Evertjan.

DU wrote on 29 mei 2005 in comp.lang.javascript:
I believe a function parameter can be a string or a value (integer,
boolean, litteral) but it is best to use a local variable.

Yes, the function parameter can be a litteral,
but not the function definition parameter.

function myFun(7,'myString'){alert('myAlert')}

This should error.
 
E

Evertjan.

StormJr wrote on 29 mei 2005 in comp.lang.javascript:
So when someone says:

window.open (URL)...

what do I put in the URL part? I saw this on a post that I searched
for.

function newWindow(URL) {
if(document.all){
window.open(URL, New Window, 'fullscreen=yes');
return false;
}
return true;
}

Please react on the anwers given, heeding the corrections.

And always quote. This is usenet, not email.
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Sun, 29 May 2005 08:21:35, seen in
StormJr said:
font: 12px verdana,helvetica,arial;

Setting font size in px is going against relevant accessibility
legislation in civilised countries.

Having verdana and helvetica together is odd, because verdana looks
unusually large for its size and is IIRC fixed-pitch, both unlike
helvetica.

***

For proper quoting when using Google for News :-
Keith Thompson wrote in comp.lang.c, message ID
<[email protected]> :-
If you want to post a followup via groups.google.com, don't use
the "Reply" link at the bottom of the article. Click on "show
options" at the top of the article, then click on the "Reply" at
the bottom of the article headers.

Since that is what the experts in this newsgroup prefer to read, it will
be to your advantage to comply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top