By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,494 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

How do I "convert" this to a "function"?

P: n/a
Probably the wrong wording but since I'm not a scripter I won't claim
to know what I'm talking about.

I got this script from www.htmlgoodies.com

<script language="JavaScript">
<!--
window.open ('photos01.html','photogallery',config='height=550 ,
width=750,toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');
-->
</SCRIPT>

Obviously, it opens a new browser window with my Photo Gallery in it.

How do I convert it into a "function" in the <head> section to call
later from a link or from within a Flash movie? And, what is the
wording that I would use to call it that would be placed in the <a
href="javascript:??> section?

Thanks for the help!

Mike
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

"Michael Stevens" <bigmikeatbigmikesdotorg> wrote in message
news:h8********************************@4ax.com...
Probably the wrong wording but since I'm not a scripter I won't claim
to know what I'm talking about.

I got this script from www.htmlgoodies.com

<script language="JavaScript">
<!-- ]
function winOpen()

{

window.open ('photos01.html','photogallery',config='height=550 ,
width=750,toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');

}
or better still

function winOpen(url)

{

window.open ( url ,'photogallery',config='height=550,
width=750,toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');

}

-->
</SCRIPT>

you can call like this

<a href=javascript : winOpen('photos01.html') > mylink </a>



Obviously, it opens a new browser window with my Photo Gallery in it.

How do I convert it into a "function" in the <head> section to call
later from a link or from within a Flash movie? And, what is the
wording that I would use to call it that would be placed in the <a
href="javascript:??> section?

Thanks for the help!

Mike
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---
Jul 20 '05 #2

P: n/a
On Sat, 26 Jul 2003 18:23:37 +0800, "Mosley Jones III"
<me@info.gov.mars> woke me from my slumber by saying:
or better still

function winOpen(url)
{
window.open ( url ,'photogallery',config='height=550,
width=750,toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');
}
-->
</SCRIPT>

you can call like this

<a href=javascript : winOpen('photos01.html') > mylink </a>


So, again remember my ignorance, in javascript the window.open
function has basically three variables (url, name, config) and they
appear in that order so that in your "better" example since url is not
inside ' ' the function assumes that the variable, in this case the
url, will be supplied when called from a link? Just so I know what's
going on. It's easier to mess with when you know what's going on.

Thanks for the help!

Mike
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 20 '05 #3

P: n/a
On 26 Jul 2003 04:38:40 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> woke me from my slumber by saying:
Michael Stevens <bigmikeatbigmikesdotorg> writes:
Probably the wrong wording but since I'm not a scripter I won't claim
to know what I'm talking about.

I got this script from www.htmlgoodies.com

<script language="JavaScript">
<!--
window.open ('photos01.html','photogallery',config='height=550 ,
width=750,toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');
-->
</SCRIPT>


Not impressive code.


I don't know that it is supposed to be ...
Obviously, it opens a new browser window with my Photo Gallery in it.

How do I convert it into a "function" in the <head> section to call
later from a link or from within a Flash movie?


Don't know about Flash, but if you want to call it from a link, you might
want to call it from more than one link, so I have made the actual URL
an argument of the function.

This should be what you need:

<script type="text/javascript">
function myOpenWindow(url) {
window.open(url,"photogallery","heigth=550,width=7 50,toolbar=no,"+
"menubar=no,scrollbars=no,resizable=no,location=no ,"+
"directories=no,status=no");
}
</script>

Every change compared to the original is deliberate and for the better.
And, what is the wording that I would use to call it that would be
placed in the <a href="javascript:??> section?


Don't use "href='javascript:...'" (it's in the FAQ, which is sadly down
at the moment: <URL:http://jibbering.com/faq/>.
Instead:

<a href="photos01.html" target="photogallery"
onclick="myOpenWindow(this.href);return false;">
link text</a>(opens in new window)

Make it obvious that clicking this link will open a new window.
Make sure that people without javascript can also use the page.


Actually, that's a good idea. I don't know how that will be
implemented in Flash but I'll have to do some checking & playing
around to see how to make it work.

One question: if someone doesn't have javascript enabled how will they
be able to use the page? Your HREF doesn't have a "javascript:..." in
it but that doesn't change the fact that it is calling a JavaScript
function, does it?

Thanks,

Mike
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 20 '05 #4

P: n/a
Michael Stevens <bigmikeatbigmikesdotorg> writes:
One question: if someone doesn't have javascript enabled how will they
be able to use the page? Your HREF doesn't have a "javascript:..." in
it but that doesn't change the fact that it is calling a JavaScript
function, does it?


If they don't have javascript (or it isn't enabled) then it will act
as a normal link with a target. The page whose URL is in the "href"
attribute, is openend in a new window with the name taken from the
"target" attribute. The javascript is never executed. The only thing
that the javascript does is to add the "config" part of the window.open
call, to change the initial size and properties of the new window.
Without javascript, you just get a plain new window, but it works.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5

P: n/a
On 27 Jul 2003 13:12:46 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com> woke me from my slumber by saying:
Michael Stevens <bigmikeatbigmikesdotorg> writes:
One question: if someone doesn't have javascript enabled how will they
be able to use the page? Your HREF doesn't have a "javascript:..." in
it but that doesn't change the fact that it is calling a JavaScript
function, does it?


If they don't have javascript (or it isn't enabled) then it will act
as a normal link with a target. The page whose URL is in the "href"
attribute, is openend in a new window with the name taken from the
"target" attribute. The javascript is never executed. The only thing
that the javascript does is to add the "config" part of the window.open
call, to change the initial size and properties of the new window.
Without javascript, you just get a plain new window, but it works.

/L


Cool.

As I was pondering how to execute that in Flash it dawned on me that I
probably won't have to worry about it. There seem to be those people
that disable everything but plain old html. So, if they're viewing the
Flash file chances are pretty good that they have javascript enabled
as well as their Flash plugin.

Thanks again,

Mike
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.