Forum Moderators: open

Message Too Old, No Replies

New Windows with no address bar and correctly sized

How to do this?

         

Magpie

12:39 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



Hey!

For my website I have some pictures. When you click on them they open up a new window... How do i get it so that when you click on a picture a new window with:

No address bar and all the other tools etc.
And the new window is the same size as the picture or what ever size i tell it to goto?

All help is much appreciated

Kind regards

Martin

Alternative Future

1:23 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello,

<script language="javascript">
function openMyWindow(){
open("PathToPage.html","PageName","scrollbars=0, width=100,height=100, top=5, left=5, title=YourTitle").focus();
}
</script>

<a href="javascript:openMyWindow()"><img src="PathToImage"/></a>

Is this what you are after?

-George

Magpie

1:31 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



cheers... i think thats it... do i put it all in like that or do i have to put it together?
if so could you show me how to put it together ready to go into my html file

Regards

Martin

Magpie

1:39 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



also

what would i write if i wanted to do the same thing but open up a flash game file (.swf) files instead of pictures

Alternative Future

2:11 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No Problem,

>>do i put it all in like that or do i have to put it together?

You would obviously have to change the PathToPage.html to your required page i.e. (.swf) file or image, and that would remain the same as shown, as long as it was located in the same directory. If it was located in another directory then you would have to add the relative path to that directory similar to "/myOtherDir/Page.html". Also the width and height elements would require changing to whatever size you require.

The JavaScript would go between the <head></head> tags in your html and the anchor tag <a> would fit in between the <body></body> tags. Does that help you any?

-George

Magpie

2:18 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



i basically have a games page on my website

could u veiw the source code for me and alter the first game to what i need to type.. all the info for the link and everything should be in the source code

sorry its jst im new to this and if i was shown 1 of them i could do the rest

Regards

Martin

[edited by: Magpie at 2:46 pm (utc) on Mar. 24, 2004]

Alternative Future

2:27 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should be what you are after!

You might want to remove the URL to your site before the mods get hold of it as it is against the TOS.

<html>
<head>
<script language="javascript">
function openMyWindow(path, PageName){
open(path,+PageName,"scrollbars=0, width=400,height=400, top=5, left=5").focus();
}
</script>
<body>
<a href="javascript: openMyWindow('/Games/2D%20Boxing.swf','2D Boxing')">2D Boxing</a>
</body>
</html>

ps - no space between the javascript colon and open.
In this example you only need the javascript function once, i.e. all anchor tags will pass in their URL to this function.

Let's know if that works for you...

-George

Rambo Tribble

2:34 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you need to dynamically size the window to accommodate images of different sizes?

Oops, nevermind, I don't think .swf files will expose their properties to JavaScript the way .img files do.

[edited by: Rambo_Tribble at 2:48 pm (utc) on Mar. 24, 2004]

Magpie

2:45 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



<tr bgcolor="#CCCCCC">
<td width="20%" height="28"><div align="center"><b>Name</b></div></td>
<td width="70%" height="28"><div align="center"><b>Description</b></div></td>
</tr><tr><td bgcolor='#E5EBF4' height="14">
<a target="_blank" href="Games/2D%20Boxing.swf">
<font color="#000000">2D Boxing</font></a></td>
<td bgcolor='#E5EBF4' height="14"><font style="font-size: 9pt">
Travel around the world and take on heavy hitting challengers!
Great stuff!</font></td></tr><tr>

this is what ive got at the moment on my webpage.. where abouts do i put in the new code you gave me and what do i change

Alternative Future

3:00 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It should be placed in where the blue text is within the red text. The javascript method should be placed between the <head></head> tags within your page.

<tr bgcolor="#CCCCCC">
<td width="20%" height="28"><div align="center"><b>Name</b></div></td>
<td width="70%" height="28"><div align="center"><b>Description</b></div></td>
</tr><tr><td bgcolor='#E5EBF4' height="14">
<a href="javascript: openMyWindow('/Games/2D%20Boxing.swf','2D Boxing')">
<font color="#000000">2D Boxing</font></a>
</td>
<td bgcolor='#E5EBF4' height="14"><font style="font-size: 9pt">
Travel around the world and take on heavy hitting challengers!
Great stuff!</font></td></tr><tr>

Does that make sense?

-George

Magpie

3:14 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



i put that in but when i test it it comes up with an internet script error :S

Martin

Alternative Future

3:18 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you post the error.

-George

Magpie

3:31 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



<tr bgcolor="#CCCCCC">
<td width="20%" height="28"><div align="center"><b>Name</b></div></td>
<td width="70%" height="28"><div align="center"><b>Description</b></div></td>
</tr><tr><td bgcolor='#E5EBF4' height="14">
<a href="javascript: openMyWindow('/Games/2D%20Boxing.swf','2D Boxing')">
<font color="#000000">2D Boxing</font></a></td>

thats the code it is now

this is the message im getting

------------------------------------------------------

Line 1
Char 2
Error: object expected
Code 0

URL: file://c:\Documents And Settings\Martin\Local
Settings\Tempoary Internet Files\Content.IE5
\73H3BL8W\[1].htm

Alternative Future

3:38 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Where have you put the <script language=javascript> within the document?
If it is between the <head> tags then in the first line of the function try putting an alert statement in to check that it is getting to it ok?
i.e.
function openMyWindow(path, PageName){
alert("am ok");
}

An alert statement helps us debug the error and check where the function might be falling over.
Other things that could prove worthwhile in the alert are alert("path = "+path+"PageName = "+PageName) this will alert us that both the required parameters are getting to the function ok.

Can you post the complete javascript you have placed into the page including the opening <head> and closing </head>

-George

Magpie

3:41 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



This is my scritpt for the whole page... change and hightlight the bits i need to do

Thanks for all this

Martin

Alternative Future

3:43 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No need to post all the page just the javascript function will do.

-George

Magpie

3:52 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



<html>
<head>
<style>
a:link, a:visited, a:active
{color: #0000CC; text-decoration: none}
a:hover {color: #343c91; text-decoration: underline}
td {
color: #000000;
font-family: Verdana, Arial;
font-size: 12px;
cellspacing: 1;
}

input, textarea {
text-decoration: none;
background-color: #EFEFEF;
font-family: Verdana, Arial;
font-size: 10pt;
font-weight: normal;
border: 1px solid #343C91;
}
body {
scrollbar-face-color: #000000;
scrollbar-shadow-color: #000000;
scrollbar-highlight-color: #000000;
scrollbar-3dlight-color: #FFFFFF;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-track-color: #000000;
scrollbar-arrow-color: #FFFFFF}}
</style>

<body bgcolor="#000000">

<table width="100%" height="1218">
<tr bgcolor="#CCCCCC">
<td width="20%" height="28"><div align="center"><b>Name</b></div></td>
<td width="70%" height="28"><div align="center"><b>Description</b></div></td>
</tr><tr><td bgcolor='#E5EBF4' height="14">
<a href="javascript: openMyWindow('/Games/2D%20Boxing.swf','2D Boxing')">
<font color="#000000">2D Boxing</font></a></td>
<td bgcolor='#E5EBF4' height="14"><font style="font-size: 9pt">
Travel around the world and take on heavy hitting challengers!
Great stuff!</font></td></tr><tr>
<td bgcolor='#D1D7DC' height="14">

Magpie

3:53 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



thats everything up to where the game link is

Martin

Alternative Future

3:57 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You haven't included the JavaScript to your page! See below:

<html>
<head>
<style>
a:link, a:visited, a:active
{color: #0000CC; text-decoration: none}
a:hover {color: #343c91; text-decoration: underline}
td {
color: #000000;
font-family: Verdana, Arial;
font-size: 12px;
cellspacing: 1;
}
input, textarea {
text-decoration: none;
background-color: #EFEFEF;
font-family: Verdana, Arial;
font-size: 10pt;
font-weight: normal;
border: 1px solid #343C91;
}
body {
scrollbar-face-color: #000000;
scrollbar-shadow-color: #000000;
scrollbar-highlight-color: #000000;
scrollbar-3dlight-color: #FFFFFF;
scrollbar-darkshadow-color: #FFFFFF;
scrollbar-track-color: #000000;
scrollbar-arrow-color: #FFFFFF}}
</style>

<script language="javascript">
function openMyWindow(path, PageName){
open(path,+PageName,"scrollbars=0, width=400,height=400, top=5, left=5").focus();
}
</script>
</head>

<body bgcolor="#000000">

Rest of your code as normal...

Also its best practice to close your <head> tags also, this is included in the code above.

-George

Magpie

4:04 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



So it should say this:

<script language="javascript">
function openMyWindow(path, PageName){
open(path,+PageName,"scrollbars=0, width=400,height=400, top=5, left=5").focus();
}
</script>
</head>

<body bgcolor="#000000">

<table width="100%" height="1218">
<tr bgcolor="#CCCCCC">
<td width="20%" height="28"><div align="center"><b>Name</b></div></td>
<td width="70%" height="28"><div align="center"><b>Description</b></div></td>
</tr><tr><td bgcolor='#E5EBF4' height="14">
<a href="javascript: openMyWindow('/Games/2D%20Boxing.swf','2D Boxing')">
<font color="#000000">2D Boxing</font></a></td>
<td bgcolor='#E5EBF4' height="14"><font style="font-size: 9pt">
Travel around the world and take on heavy hitting challengers!
Great stuff!</font></td></tr><tr>

------------------------------------------------------

tell me and highlight if i need to change n e thing

Thanks

Martin

Alternative Future

4:06 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes including the rest of your code that was in place.

The red was additional stuff to place on the page.

-George

Magpie

4:08 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



<script language="javascript">
function openMyWindow(path, PageName){
open(path,+PageName,"scrollbars=0, width=400,height=400, top=5, left=5").focus();
}
</script>
</head>

do i not need to change n e thing there?

Alternative Future

4:23 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No nothing to change within the javascript.

<script language="javascript">
We are telling the browser that this piece of script is javascript

function openMyWindow(path, PageName){
Here we are creating a function with the name of openMyWindow, into this function we are passing two parameters named path and PageName the { begins the function (everything enclosed within the two {} deals with our function)

open(path,+PageName,"scrollbars=0, width=400,height=400, top=5, left=5").focus();
Here we are calling on the JavaScript method open() in which we pass the two parameters path and PageName we set the height width and location of the new window here also. The focus() sets the new window in front of the opening one.

}
Close the function.

</script>
Close the script.

openMyWindow('/Games/2D%20Boxing.swf','2D Boxing')">
From your anchor tag <a> we call on the javascript function openMyWindow, pass the two parameters into this function that are related to our anchor and the new window opens related to our request.

So in answer to your question - you have nothing else to do with the javascript function. All you have to do now is pass in two parameters that are related to the window you wish to open.

Hope this helps.

-George

Magpie

4:44 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



this is what ive put in now

<body bgcolor="#000000">

<script language="javascript">
function openMyWindow(path, PageName){
open(path,+PageName,"scrollbars=0, width=400,height=400, top=5, left=5").focus();
}
</script>
</head>

<table width="100%" height="1218">
<tr bgcolor="#CCCCCC">
<td width="20%" height="28"><div align="center"><b>Name</b></div></td>
<td width="70%" height="28"><div align="center"><b>Description</b></div></td>
</tr><tr><td bgcolor='#E5EBF4' height="14">
<a href="javascript: openMyWindow('/Games/2D%20Boxing.swf','2D Boxing')">
<font color="#000000">2D Boxing</font></a></td>
<td bgcolor='#E5EBF4' height="14"><font style="font-size: 9pt">
Travel around the world and take on heavy hitting challengers!
Great stuff!</font></td></tr><tr>

------------------------------------------------------

it woks... but the link is not working... when i click on it its saying page can not be displayed

Martin

Alternative Future

4:49 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This red code comes before the blue code.


<script language="javascript">
function openMyWindow(path, PageName){
open(path,+PageName,"scrollbars=0, width=400,height=400, top=5, left=5").focus();
}
</script>
</head>

<body bgcolor="#000000">

If it is not showing then it has to do with your paths.
Try adding your domain to the path openMyWindow('http://www.yourdomainname.com/Games/2D%20Boxing.swf','2D Boxing')">

Remember yourdomainname is your actual domainname not the one shown.

-George

Magpie

4:53 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



i havn't got just the 1 game on my site.. i have quite a few... so what should that link be

Magpie

4:54 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



OK IVE DONE IT!

THANKS FOR ALL THE HELP!

BIG HUGS ALL ROUND!

keep an eye on this page tho... knowing me ill screw somin up lol

Martin

Alternative Future

4:56 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right, see when you currently click on any of the games copy and paste the Address/URL/path from the browser window into the openMyWindow('http://www.webmasterworld.com/forum91/1489-2-15.htm','WebMasterWorld')"> being an example of a copy and paste from this page (the one we are currently viewing and using to post these messages on)

Try that out.

-George

Alternative Future

4:58 pm on Mar 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well Done!

Runs off into the Horizon for a well deserved break lol ;-)

-George

Magpie

5:04 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



lol

Cheers dude! Really appreciate it! Dont forget suncream

Martin