Forum Moderators: open

Message Too Old, No Replies

Writing a URL as a javascript variable

         

scorpion

12:16 am on Mar 29, 2003 (gmt 0)

10+ Year Member



when you have something like

var="sample/images/myimage.jpg";

is this relative to the file and directory in which the javascript is in?
e.g if it runs in mydomain.com/test/, it will be mydomain.com/test/sample/images/myimage.jpg?

var="/sample/images/image.jpg";

is this relative to the server root?

Thanks.

txbakers

12:52 am on Mar 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It all depends how you use it. All you did was declare and populate a javascript string variable. The language itself doesn't know what is inside the quotes.

if you do something like this:

var URL = "";
URL = "mydomain.com/test/"

var path ="sample/images/myimage.jpg";

var URL += path;

location.href= URL;

then yes, the path will be relative to the root.

toadhall

12:54 am on Mar 29, 2003 (gmt 0)

10+ Year Member



Short answer?

Try it.

T

scorpion

1:05 am on Mar 29, 2003 (gmt 0)

10+ Year Member



the code is:

function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}

and the call is

MM_openBrWindow('samples/images/animage.jpg');

txbakers

1:23 am on Mar 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you also need the commas:

MM_openBrWindow('samples/images/animage.jpg','','');