Running a Script from within a Script

I am trying to use an ifelse statement to run a . The problem is that when the if statement gets to the , the whole thing dies.

Here is the basic code (trying to keep it as simple as possible):


var mlc = document.location.href;
var goodmlc = (mlc.indexOf('C:%5C') > -1);
if (goodmlc == true)
{

}
else
{

}

The jist of the code is if the URL contains "C:" then do nothing, otherwise run the .

I have tried a number of variations, all which throw errors. I also thought about throwing this into a function and just calling the function in the ifelse, but I run into the same problem of the . Any help would be greatly appreciated.

Comments

  • Because of how browsers validate HTML, this is not possible. Suggest using relative path as opposed to absolute path to build your site on a local machine
  • Thanks for the validation. I didn't think it was possible, but wanted to ask to make sure there wasn't something I missed.
  • You may still run URL conditional code... I did a lot of that with 'buy now' buttons.

    You just can't do it with HTML tags because when the browser finds the opening tag, it searches for the closing tag before executing any scripts. This behaviour is not limited to browsers as many server scripts act the same way for efficiency
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories