How do I hide a button from external javascript

0 favourites
  • 6 posts
From the Asset Store
J-BoB Game Button Sound Pack comes with 300 high-quality sound effects
  • Hello together

    I have a javascript which should show a button. Only when user ist set the button should be shown.

      var url = document.URL;
      var user = url.split("&user=");
      if(user != "") {
      user = user[1].split("&");
      }
    
      if(user[0] != "NOUSER" && user[0] != "") {
      // Show Button
      }[/code:20409sjf]
    
    So now my question is how can I add this function to Construct 2, so that a button is set to invisible.
    
    GREETS
  • Using the "Button set invisible" action?

    Actually if you want the button invisible on start you could choose to set it invisible in it's properties and only set it visible when needed, or create the button object when needed using a system create action.

    I'm not sure why you would want to use an external script for that..

  • Ok and how can I check if the user variable is set in Construct2?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • System compare variable User is not ""

    You might want to look at some tutorials and read the manual..

  • But I don't have the variable in Construct 2. it's only a browser url parameter

  • Through the browser object you can get all the info you want..

    Browser.Title

    The current HTML document's title.

    Browser.Domain

    The current domain, e.g. scirra.com.

    Browser.Hash

    The string after the hash at the end of the URL, including the hash. For example, if the current URL is http://scirra.com/mygame/index.html#teapot, this returns #teapot.

    Browser.PathName

    The path relative to the domain in the URL. For example the path name of http://scirra.com/mygame/index.html#teapot is /mygame/index.html.

    Browser.Protocol

    The current protocol, usually either http: or https:.

    Browser.QueryParam

    Return a query string parameter by name. For example, if the URL ends with index.html?foo=bar&baz=wan, QueryParam("foo") returns bar and QueryParam("baz") returns wan.

    Browser.QueryString

    Return the full URL query string including the question mark. For example, if the URL ends with index.html?foo=bar&baz=wan, this returns ?foo=bar&baz=wan.

    Browser.Referrer

    Get the previous page that linked to this page, if any.

    Browser.URL

    Get the complete current URL in the browser address bar, including the protocol.

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