How to Execute Javascript Code Using Variable in URL -


I'm really new to javascript and I have some problem how to get the following to work. My goal is to execute a certain JavaScript action, when a page loads and a variable added at the end of the URL that executes the Javascript Action. The URL of the page on which I want to apply it Each of the "Extended" buttons, which operates JavaScript, drop-downs of a fixed area of ​​the page Finally, I would like to be able to create a URL which will automatically drop down a certain category when the page is loaded. Can anyone explain this process to me? Thanks in advance for any help!

You already have a call calling function: toggle2 () , Which, in the end, takes two parameters to be equal for all categories except for a number, then create the URL that contains the number:

Then use that number as a regular expression using the location Find in .hash . It's strong enough to handle multiple URL parameters, so you should decide to use them in the future: / [\ # & amp;] cat = (\ d +) / but , If you never add anything else to the URL, you can use one very easy one like / (\ d +) / .

, to make your two parameters and call toggle2 () , this is a simple matter to use that number.

This should work:

  window onload = function () {if (/[\#&]cat=(\d+)/.test(location Hash)) {var cat = parseInt (RegExp $ 1); If (cat & gt; & amp; amp; & amp; & amp;; & amp;; cat & lt; 13) {toggle2 ("Toggle" + Cat, "displayText" + Cat); }}}    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -