How do I hide a button from external javascript

Get help using Construct 2

Post » Mon Jun 01, 2015 8:36 am

Hello together :)

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

Code: Select all
  var url = document.URL;
  var user = url.split("&user=");
  if(user != "") {
  user = user[1].split("&");
  }

  if(user[0] != "NOUSER" && user[0] != "") {
  // Show Button
  }


So now my question is how can I add this function to Construct 2, so that a button is set to invisible.

GREETS :)
B
4
Posts: 12
Reputation: 224

Post » Mon Jun 01, 2015 9:39 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 01, 2015 9:48 am

Ok and how can I check if the user variable is set in Construct2?
B
4
Posts: 12
Reputation: 224

Post » Mon Jun 01, 2015 9:52 am

System compare variable User is not ""

You might want to look at some tutorials and read the manual..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 01, 2015 10:33 am

But I don't have the variable in Construct 2. it's only a browser url parameter
B
4
Posts: 12
Reputation: 224

Post » Mon Jun 01, 2015 10:39 am

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests