MarkJames Posted May 8, 2014 Share Posted May 8, 2014 Hi, I'm a very very very very basic html programmer. Emphasis on the basic. I'm trying to add a simple web page to my personal web space that lets me turn the lights on and off in the house. It's purely meant for local use so all the links map within my 192.168.0.xxx network space. I've created the page and added all the necessary rest commands and it works perfectly. I've got on and off text hyperlinks to each appropriate rest command - one for each ON and one for each OFF. The only thing of it is that when I click the link the browser treats it as it should - as a link - and opens the rest command result in either a new tab or in the same tab. Either way the focus shifts to a tab/page/browser window other than the one with all my buttons. I'd like it to stay on the same page so I can press additional buttons without having to switch back. Ideally I don't care to see the rest command result at all. I'm sure this is a snap for all the web design savvy folks out there. I'd sure appreciate a nudge in the right direction. Thanks, Mark Link to comment
tracknut Posted May 8, 2014 Share Posted May 8, 2014 You're doing this all with html, ie putting the rest command inside a ? If so, I'm not sure what you're asking is possible. I do my rest on the server via php curl commands, but if you're brand new to html, php could be exciting... Link to comment
MaddBomber83 Posted May 8, 2014 Share Posted May 8, 2014 Take a look at the bottom link in my signature. Here I set up a FosCam using the HTML interface of the ISY Web Server. When you send a REST command (as you pointed out) it returns a result and this is undesirable for a web page where the links are just buttons. What you want to do is tell that link to open someplace else. You'll often see this as a pop up or new tab. I went the route of setting up a frame in the web page that it would go to. This has the benifit that you don't really see it, and you stay on the page where your buttons are. It is called an iFrame. Up/Left In the above link, the target is an iFrame called 'control'. In the above code is the iframe. I place mine on the bottom of the page. That frame will display the reply (such as 200). In the below image you'll see my interface and at the very bottom you'll see the iframe (cut off). Link to comment
MaddBomber83 Posted May 8, 2014 Share Posted May 8, 2014 Also as a note, the Web Server lets you set your page as the default. So when you go to your isy it displays your page instead of the default one. I found adding a button to go to the normal one was helpful for accessing things I have not programmed in yet. UD Ajax In that example, the target '_self' is the full page. Link to comment
MarkJames Posted May 8, 2014 Author Share Posted May 8, 2014 That worked perfectly! Thanks. I just cut and pasted your iframe line into my code and reset the targets of the hyperlinks to it. Much appreciated! Mark Link to comment
G W Posted May 8, 2014 Share Posted May 8, 2014 Mark, you should look at jury and JSON. It will do exactly what you want. Sent from my SM-N900P using Tapatalk Link to comment
MarkJames Posted May 8, 2014 Author Share Posted May 8, 2014 As an aside - using the method maddbomber83 posted I changed the size of the iframe down to 1x1. That effectively makes it invisible and does what I wanted perfectly. Thanks again, Mark Link to comment
MaddBomber83 Posted May 8, 2014 Share Posted May 8, 2014 The script above declares a variable,assigns a value to it, displays the value, changes the value,and displays the value again. Link to comment
Recommended Posts