skateme
07-23-2011, 09:53 PM
I'm trying to determine whether a word exists in the URL and if so, change the CSS of a div.
I know how to do each task individually, but combining the two is giving me trouble.
So far I have:
function checkSent(divname)
{
if(document.URL.indexOf("sent") >= 0)
*document.getElementById(success).style.display = 'block';
}
var sentornot = checkSent();
// If the URL contains the word, sent, then change the display of the element "success" to block
I can successfully determine whether the string exists in the URL by adding an alert, but the Javascript to change the CSS doesn't work.
The CSS for the div element "success" is as follows:
#success {
display: none;
}
Any help is appreciated! Thanks!
Edit:
If needed, this is the code I used to test whether the "check URL" portion works:
function checkSent(divname)
{
if(document.URL.indexOf("sent") >= 0) {
alert("found");
document.getElementById("success").style.display = 'block'; //this line doesn't work :(
}
else{ alert("not found"); }
}
I know how to do each task individually, but combining the two is giving me trouble.
So far I have:
function checkSent(divname)
{
if(document.URL.indexOf("sent") >= 0)
*document.getElementById(success).style.display = 'block';
}
var sentornot = checkSent();
// If the URL contains the word, sent, then change the display of the element "success" to block
I can successfully determine whether the string exists in the URL by adding an alert, but the Javascript to change the CSS doesn't work.
The CSS for the div element "success" is as follows:
#success {
display: none;
}
Any help is appreciated! Thanks!
Edit:
If needed, this is the code I used to test whether the "check URL" portion works:
function checkSent(divname)
{
if(document.URL.indexOf("sent") >= 0) {
alert("found");
document.getElementById("success").style.display = 'block'; //this line doesn't work :(
}
else{ alert("not found"); }
}