Running a Script from within a Script - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Running a Script from within a Script

acrinsdacrinsd Posts: 3Member
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)



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.


  • CyGuyCyGuy Posts: 312Member
    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
  • acrinsdacrinsd Posts: 3Member
    Thanks for the validation. I didn't think it was possible, but wanted to ask to make sure there wasn't something I missed.
  • CyGuyCyGuy Posts: 312Member
    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.