Forum Moderators: open
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
>>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
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]
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
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
<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
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
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
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">
<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
<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
<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
<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
<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
Try that out.
-George