Assign javascript function to unbounce buttons


#1

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

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.


#3

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.