Two URL's in one HTML Button. Is it possible?

Hello guys, i’m currently developing a site with arduino project which is WEB SWITCH.

I got codes like this…

//Prints the ON Buttons
    client.print("<td>");
    //client.print(buttonText[var]);
    client.print("<INPUT TYPE=\"button\" VALUE=\"ON ");
    //client.print(buttonText[var]);
    client.print("\" onClick=\"parent.location='/?H");
    client.print(var);
    client.print("'\"></td>\n");

    //Prints the OFF Buttons 
    client.print(" <td><INPUT TYPE=\"button\" VALUE=\"OFF");
    //client.print(var);
    client.print("\" onClick=\"parent.location='/?L");
    client.print(var);
    client.print("'\"></td>\n");

It prints ON and OFF button in my site.
whenever i click those buttons…
for example, i clicked on… the location will be “192.168.0.200/?Hvar”
after visiting that location i want it to instantly redirect to “192.168.0.200/”
is it possible?

Please help me.

I think that what you are requesting may astonish the user, but I will let it be.

The onClick method could execute a function that loads from one URL, waits a while, and then loads from another.

Another way would be to add an onLoad method. The onClick method would load one URL, and the onLoad method would execute a function that loads another URL. I am uncertain whether onLoad is allowed on a button, however.

Caveat: I haven't tried this myself, but it may point the way to a plan.

I wonder if the OP is really wondering if it is possible for the Arduino code to create one URL on one occasion and a different URL for the same button on another occasion. If so, the answer is YES.

...R

You could send an HTTP 302 response with the location you want to redirect the user to: HTTP 302 - Wikipedia

for example, i clicked on.. the location will be "192.168.0.200/?Hvar"
after visiting that location i want it to instantly redirect to "192.168.0.200/"
is it possible?

You might look at the below tutorials on redirection setting the refresh time to 0.

https://www.google.com/search?as_q=html+redirect+tutorial&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=&as_occt=any&safe=images&as_filetype=&as_rights=

That sounds like... not very good behavior that you're trying to achieve.

I'd have the onClick fire off an XHR to a different URL answered by the Arduino that would just do the action and not have to return anything to the client other than a 200 OK. Less work for the Arduino, and a better UX for the user.

Also, you forgot to use the F() macro on those string constants you're sending to the client.

The redirects are very common with the "click thru" sites that collect data and which count clicks to pay people for the click thrus they generate.