Hi all.
What I am trying to do, is get the current pages URL, and then using that to determine what content (held in a variable in the external .js) will be displayed.
I have created the following in an external JS file, just to purely see whether the function is working or not:
function displayCategory() {
if (window.location=" {
document.write ("Internet Connection")
}
else {
document.write ("Mobiles")
}
}
now, in the page where I want to call the function, i have :
<a href="javascript:void(0)" onclick="displayCategory()">link</a>
So, above is obviously just a basic check, BUT either way, I only ever get "Internet Connection" written to the document. Is it my if/Else statement no working? What would be the best way to go about:
A)determining the current page URL and
B) Running a function/displaying a variable based on the url.
PLease help somebody.
D
What I am trying to do, is get the current pages URL, and then using that to determine what content (held in a variable in the external .js) will be displayed.
I have created the following in an external JS file, just to purely see whether the function is working or not:
function displayCategory() {
if (window.location=" {
document.write ("Internet Connection")
}
else {
document.write ("Mobiles")
}
}
now, in the page where I want to call the function, i have :
<a href="javascript:void(0)" onclick="displayCategory()">link</a>
So, above is obviously just a basic check, BUT either way, I only ever get "Internet Connection" written to the document. Is it my if/Else statement no working? What would be the best way to go about:
A)determining the current page URL and
B) Running a function/displaying a variable based on the url.
PLease help somebody.
D