Assign javascript function to unbounce buttons

  • 9 November 2013
  • 2 replies
  • 60 views

How can i accomplish this?
right now, i can only enter a URL in the parameter for an unbounce button.

trying to access the button using javascript (see below) does not work either.

any ideas?

document.getElementById(’#lp-pom-button-16’).onclick = function() {
window.location.href = theURL2;
}


2 replies

i guess to be clear:

i need to assign the URL to the button dynamically.
depending on a parameter inside the URL (which i am able to successfully pull).

now all i have left to do is to assign the dynamically created URL to the button, so that when it is being clicked, the user is being taken to that URL.

looking and looking and trying to pull my hair out - all did not help.

ok. figured it out.
not a javascript pro.

document.getElementById(‘lp-pom-button-16’).href = theURL2;

*removed the hashtag in front of the element id
& instead of calling a function on click, i had to just refer to the href
& i packed it all into a “window.onload” function in order to be sure that the element had been loaded by the time i am trying to adjust its href property.

Reply