I have build a basic web page with 2 links. The links are targeted to a relay, and once you click link the relay activates. The issue I am having, after the link is clicked I get to a blank page.
Problem: I want to be redirected back to the original page once it is executed. I have heard <meta = Refresh command would do this but it keeps refreshing the original page. Maybe the <meta = Refresh command is not want I want? Maybe I should keep it simple and have it redirect to the orginal page once done. (dumb question; how do I do that?)
else if (req.indexOf("/Full") != -1){ //brings to Webpage 192.168.1.59/Full
client.flush();
client.println("HTTP/1.1 200 OK");
client.println("");
client.println("<html>");
client.println("<HEAD>");
client.println("<TITLE>Garage Door</TITLE>");
client.println("</HEAD>");
client.println("<BODY>");
String s1 = "Garage Door 1 is ";
s1 += (Door1_Status);
s1 += "</html>\n";
client.println(s1);
client.println("
");
String s2 = "Garage Door 2 is ";
s2 += (Door2_Status);
s2 += "</html>\n";
client.println(s2);
delay(1);
client.println("
");
client.println("<h1>Click <a href=\"/gpio/3\">here</a> trigger Right Garage door
</h1>");
client.println("</BODY>");
client.println("</html>");
Serial.println("Client disonnected");
Serial.print("Door No. ");
Serial.println(Door);
Serial.println(s);}
else if (req.indexOf("/gpio/3") != -1){ //This is where the target of the link. I will trigger a relay
val = 1;
Door = 1;
digitalWrite(Door1trigger, val);
delay (500);
val = 0;
digitalWrite(Door1trigger, val);
client.flush();
client.print ("<meta HTTP-EQUIV='REFRESH\' content='0; url=http://192.168.1.59/Full>");
//i think this is wrong. I need it to go back to the "/Full" page. How do I do that??
delay(1);
Serial.println("Client disonnected");}
I have heard <meta = Refresh command would do this
Then, you heard incorrectly. The refresh tag tells the browser to call the server again after the specified interval IF the current page is still being displayed.
String s1 = "Garage Door 1 is ";
s1 += (Door1_Status);
s1 += "</html>\n";
client.println(s1);
client.println("
");
Why do you bother sending more data after the closing html tag?
(Why) (is) (Door1_Status) (in) (parentheses) (?)
client.println("<h1>Click <a href=\"/gpio/3\">here</a> trigger Right Garage door
</h1>");
Why do you do a redirect, if you don't want a redirect to happen?
What I want is. After the command is finished I want it to return to 192.168.1.58/Full.htm
else if (req.indexOf("/gpio/3") != -1){ //This is where the target of the link. I will trigger a relay
val = 1;
Door = 1;
digitalWrite(Door1trigger, val);
delay (500);
val = 0;
digitalWrite(Door1trigger, val);
client.flush();
I have developed a Web page. In the webpage there is a hyper link (called gpio3)
When clicking on the gpio3 link it will trigger a relay to open the garage door called "digitalWrite(Door1trigger, val);". Once this is complete I want it to return to the /Full page.
Once it returns to the /Full page the Arduino will refresh and indicate if the garage door is either open or closed. If I want to open/close the garage door again, all I need to do is click on the link again to activate the relay.
Currently:
I have the webpage with the hyper link. I click on the link which triggers the relay, but brings me to a blank page and doesn't redirect me back to the /Full.html site.
PaulS:
Why are trying to redirect to google's site?
Have you stopped making the button do a different re-direct?
Why google? It is just an example. Google is not the point of the post. The point of the post is that I want it to redirect to a specific site. I choose Google to simply things.
> ```
>
>
>
> And you should probably put the 'meta' tag in the header and your text in the body.
Thanks for you help. I did what you directed. The page doesn't redirect to google.com after my "digitalWrite" was executed. This is what I created. Can you tell me what I did wrong. I put the meta command in both body and header as you directed.
You're coming uncomfortably close to demanding help.
This site isn't staffed by a tech support forum.
Most that assist also have lives that exist outside the forum.
I'm this close to speaking out against those who toss their problems over the wall not only hoping that someone will help but many times expecting someone to do their research and debug and revamp their code for them.
Thanks, I like when they help me and give me direction. But I have a problem when I follow there direction and code it as per their direction and when it doesn't work. They are high and dry.