0

This is my first time on here. I have a small web server running on an Arduino that is able to turn 8 relays on and off.

I can control these by URLs.

http://192.168.1.178/?led1=on
http://192.168.1.178/?led1=off

The web server running on the Arduino is quite basic in looks. I have another page that I have created that I would like to have on and off sliders on.

So far I've tried many things. But after using a slider or button the URL link is followed and the basic web server is shown.

Is there away to do this with out having the URL followed?

I have googled and experimented but have come up with nothing I can use.

My coding knowledge is extremely basic. I have this style of button that I like but am unsure how to make it use a URL and not follow it.

HTML and CSS of the button I like.

    .onoffswitch {
        position: relative; width: 90px;
        -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
    }
    .onoffswitch-checkbox {
        display: none;
    }
    .onoffswitch-label {
        display: block; overflow: hidden; cursor: pointer;
        border: 2px solid #999999; border-radius: 20px;
    }
    .onoffswitch-inner {
        display: block; width: 200%; margin-left: -100%;
        transition: margin 0.3s ease-in 0s;
    }
    .onoffswitch-inner:before, .onoffswitch-inner:after {
        display: block; float: left; width: 50%; height: 30px; padding: 0; line-height: 30px;
        font-size: 14px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
        box-sizing: border-box;
    }
    .onoffswitch-inner:before {
        content: "ON";
        padding-left: 10px;
        background-color: #34A7C1; color: #FFFFFF;
    }
    .onoffswitch-inner:after {
        content: "OFF";
        padding-right: 10px;
        background-color: #EEEEEE; color: #999999;
        text-align: right;
    }
    .onoffswitch-switch {
        display: block; width: 18px; margin: 6px;
        background: #FFFFFF;
        position: absolute; top: 0; bottom: 0;
        right: 56px;
        border: 2px solid #999999; border-radius: 20px;
        transition: all 0.3s ease-in 0s; 
    }
    .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-inner {
        margin-left: 0;
    }
    .onoffswitch-checkbox:checked + .onoffswitch-label .onoffswitch-switch {
        right: 0px; 
    }
<!DOCTYPE html>
<html>
<head>



    <div class="onoffswitch">
        <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" checked>
        <label class="onoffswitch-label" for="myonoffswitch">
            <span class="onoffswitch-inner"></span>
            <span class="onoffswitch-switch"></span>
        </label>
    </div>



</head>

Thanks for your time Michael

  • 1
    How about placing you content inside the `body` tag and not the `head`? To stop URLs from being followed, just add a `onclick="return false;"`, or even better, add an `eventListener` to every link that uses `event.preventDefault()`. However, you are _not using any links_. Your HTML does not contain an `a` tah with an `href` attribute, so there is simply no link in your html. – somethinghere Sep 18 '15 at 15:42
  • @dave yeah could be, if he had any `a` tags :) – somethinghere Sep 18 '15 at 15:45
  • Can you show us the source code from `http://192.168.1.178/?led1=on`? – hopkins-matt Sep 18 '15 at 16:29
  • Matt I can not seem to add the source code by editing my post it does not display correctly and I tried a screen shot but I need +10 rep. Not sure if this is allowed but I uploaded the screen shot here http://postimg.org/image/uf8yie7rd/ – Michael Harker Sep 19 '15 at 06:23

0 Answers0