Software Archive
Read-only legacy content
17061 Discussions

Change href of sprite button in JavaScript

Ruben_S_
Beginner
418 Views

Hi all, 

I have a javascript function in which I want to set the href of a sprite button. Nothing seems to work. I have tried

- document.getElementById('button').href

- document.getElementById('button').src

with jQuery via setAttribute..

Anyone who can tell me what I should do to set the href of a sprite button? 

Thanks

0 Kudos
1 Solution
Chris_P_Intel
Employee
418 Views

If it is the "Sprite Button" from App Designer, just register a click handler on it.  

In the Interactivity pane in App Designer find your button and in the right column choose "Custom Script".  Then click the "Edit Script" button - that'll add a handler for you and you can just put whatever code you want in there.

View solution in original post

0 Kudos
4 Replies
Elroy_A_Intel
Employee
418 Views

What type of element is 'button'? The HTML href attribute can only be added to a HTML <a> tag.

0 Kudos
Chris_P_Intel
Employee
419 Views

If it is the "Sprite Button" from App Designer, just register a click handler on it.  

In the Interactivity pane in App Designer find your button and in the right column choose "Custom Script".  Then click the "Edit Script" button - that'll add a handler for you and you can just put whatever code you want in there.

0 Kudos
Chris_P_Intel
Employee
418 Views

Where are you attempting to go ? To another file? To a #section on the page?

0 Kudos
Ruben_S_
Beginner
418 Views

I have registered a click handler for it. 

document.getElementById('button').onclick = (function(value){ code... });

This did the trick

 

0 Kudos
Reply