Go to URL -> Execute javascript -> prceed to layout 2

  • Would it be possible to make something like:

    Button - on press -> go to url - - target self

    -> execute javascript (alert("hello"))

    -> go to Layout 2

    For now, all I can get is a browser opening destination url, but not executing javasctipt (alert for example) nor proceeding to Layout 2...

  • Target self means it's going to go to a new url, and leave the current one

    You can't change your shirt, if it's at your house, and you are at the neighbours.

  • Hi, thanks, but target blank opens a new tab and runs the javascript alert on the initial tab and not on the new one... Is there a way to "take the shirt with you" to the neighbours hose, change it there and then get back home?

  • You will have to ask the neighbours.

  • You can't run javascript in other tabs. That would be a huge security flaw in the web. For example a malicious page could open your Facebook page and send all your photos to the malicious page owner. So actually it's a pretty good thing you can't do that.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can't run javascript in other tabs.

    I understand the security risk, but could I run JS in same tab? For example, if I'd like to make a game that opens website in the background with some sort of overlay UI built in C2? I'd like to use some sort of buttons that would fire JS on the page in the background (find some elements, change inner html, change style of divs etc...) (Idea is sort of an educational game/ap)

  • I think you might be able to overlay an iframe, but you still can't force it to run your own JS, for the same reasons.

  • Couldn't you achieve the same effect using local storage?

    Not sure best way but maybe:

    On layout start -> set global variable to random number

    On button -> store global variable into local storage, open new window

    If global variable =! local storage then fire javascript

    I actually haven't used local storage yet so doubt that is exactly how it would go but hopefully that conveyed the premise. I've used mySQL tables before and feel like I could achieve this with them, but figured local storage could as well and would be much simpler

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)