Howdy, Stranger!

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

Game links triggered by 'javascript:state.display( )' don't work in non-Chrome browsers....

I made this game using SugarCane:

I rely on links triggered with JavaScript like:
<a href="javascript:state.display('LINKNAME',this);"></a>

It works perfectly in Google Chrome, but it has just been brought to my attention that Firefox or Internet Explorer decides to self-destruct instead. It will display a blank page with the text "[object HTMLDivElement]" on it, rather than... I guess displaying the HTMLDivElement I wanted it to.

The answer might already be out there someplace and I'm looking through everything I can find, but please let me know if you know or can think of a possible solution for this issue.

Thanks a lot! :)


  • edited November 2015
    Found the solution! :)
    Super simple, but super frustrating too!

    People familiar with JavaScript probably know this well, but Firefox will accept these kinds of links instead and the void(0) tells the browser to stay on the same page and not go to some weird plain-text alternate universe:
    <a href='javascript:void(0)' onclick='state.display("PASSAGENAME")'></a>

    More info on internal links here:
  • edited November 2015
    I haven't looked the at the game, but is there some reason you aren't using one of the standard link markups?

    Wiki link:
    Anchor element with the data-passage attribute:
    <a data-passage="passage_name">link_text</a>
  • Yup, I wanted to have multiple links using only one image. :)
  • edited November 2015
    I have no idea how that relates to my question (seriously). My second example, the anchor element with the data-passage attribute, should be completely equivalent to your onclick hack, save that Sugarcane actually knows that it's a passage link. Maybe there's some issue with that, but your response doesn't really make that clear.

    I'm not trying to badger you here, but you seem to be going out of your way to do something for which there's an existing standard mechanism.
  • edited November 2015
    Actually I responded like that, because I tried it your way and it didn't work (to add multiple links that way onto a single image). If it does the same thing but actually works then there's no reason not to do it that way. It might be a SugarCane issue.
Sign In or Register to comment.