Click to See Complete Forum and Search --> : Javascript help. Newbie opening new window


boroarke
05-13-2003, 02:10 PM
Please bare with me; I am a newbie when it comes to JavaScript and Im having problem with an open new window script. On my website I am designing, I have a link that when the user clicks on it, it opens up a new small window with additional items they can choose from. This is the code I am using.
In the head of the HTML I have::

<SCRIPT language="JavaScript">
<!--hide
function newwindow1()
{
window.open(‘www.anysite.com’,'jav','width=500,height=400,resizable=no');
}
//-->
</SCRIPT>


In the body of the HTML, where the link is located, this is the code I have:


<a href="javascript:newwindow1()"><span style="font-weight: 700">
<font face="Verdana" style="font-size: 9pt" color="#223767">New 2004 models</font></span></a>



Now, this is where I am running into problems. In the head, I know I need to put the path of the file where the ‘www.anysite.com’ is but the file I want it to link to is not uploaded to my site yet so there is no URL to enter. I am still designing everything so the new page is still on my c: drive. The location of the actual file is C:\install.htm. If I replace the ‘www.anysite.com’ with ‘c:\install.htm’ and then try to open that link to test it, I get the “Page can not be viewed or missing” error. I know what I would need to enter if the page was already on my site but I do not want to upload any of the pages until I have everything completed. Could someone explain what I need to enter in replace of the ‘www.anysite.com’ so I can link to the file on my hard drive? Does that make sense? Thanks in advance everyone for your help.
:confused:

pyro
05-13-2003, 02:17 PM
Try using relative paths. For instance, if the page you want to open is called 'page.htm' as is located in a subdirectory called 'required' you would link to it like this:
window.open('required/page.htm'...) If you need to move up a directory, use ../page.htm. Hope that helps...

khalidali63
05-13-2003, 02:21 PM
Aspyro mentioned,Backslash may be a good idea in widnows environment,but you should keep forward slash for separation of files/folders when it comes to internet...

Charles
05-13-2003, 02:59 PM
Be careful, that method of opening a new window will give you a link that does nothing for the one in ten users that do not use JavaScript. To keep things working use instead:

<a href="http://www.w3.org/" onclick="window.open (this.href, 'child', 'height=400,width=300'); return false">style="color:#223767; font-family:Verdana, sans-serif; font-size:9pt; font-weight:700">New 2004 models</a>

And don't worry about using forward slashes, they're fine in Windows.

boroarke
05-13-2003, 03:14 PM
Thanks for your help so far everyone!
Charles- I tried your html and when I enter it in

<a href="http://www.w3.org/" onclick="window.open (this.href, 'child', 'height=400,width=300'); return false">style="color:#223767; font-family:Verdana, sans-serif; font-size:9pt; font-weight:700">New 2004 models</a>

It changes the link on my page from New 2004 Models to:

"style=color:#223767; font-family:Verdana, sans-serif; font-size:9pt; font-weight:700">"New 2004 models"

How do I make it so the link they click on reads New 2004 Models. and not "style=color:#223767; font-family:Verdana, sans-serif; font-size:9pt; font-weight:700">"New 2004 models"?
Thanks again everyone!!

khalidali63
05-13-2003, 03:22 PM
There is a typing error..
remove this right angle bracket

false">style="color and change it to

false" style="color..rest of the line here

boroarke
05-13-2003, 03:35 PM
Great! Thanks everyone, it was just what I was looking for!!