MyBB Community Forums

Full Version: Trying to make a certain script.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
OK, so I am going to make and release a theme for MyBB, or at least I plan on it.
BUT, I want to make a script for the theme that lets the user know if he or she has the right image file.
I have
var img1 ="help.gif"
function imgcheck() {
if (img1 == "help.gif"){
window.location="help.php";
}
else{
alert("Hey! Fix the image!")
}
}
But its not working.
Is there something im doing wrong?
Your code really doesn't make sense for one...

Also, I don't believe there's really any *good* way to detect this through Javascript - I guess you could possibly use a timeout to see if all the images have been loaded, but this will stuff up for people on slow connections.
A better solution would perhaps be a PHP script to check if all the files exist on the server.
Enter a full hyperlink for window.location.

window.location = "http://www.somesite.com/help.php"

window.location is used for redirection, by the way. Are you sure that's what you want to do? And what Zinga said; Javascript probably isn't the way to go for something like this. PHP looks more qualified for this.