Results 1 to 6 of 6

Thread: HTML button with link

  1. #1
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default HTML button with link

    Hi
    I need to create a HTML button that leads me on click to a website (i.e. google.de)

    can anybody send me the code?

    Thank you (I am a beginner)
    Last edited by djr33; 01-17-2012 at 01:44 AM.

  2. #2
    Join Date
    Mar 2011
    Location
    N 11 19' 0.0012 E 142 15' 0
    Posts
    1,521
    Thanks
    41
    Thanked 89 Times in 88 Posts
    Blog Entries
    3

    Default

    Welcome juliememe to the forums

    HTML Code:
    <input type="button" onclick="location.href('http://www.google.com');" value="Redirect">

    or using a function


    This should go in the <head> </head> section of your page.
    HTML Code:
    <script type="text/javascript">
    <!--
    function redirect() {
    	window.location = "http://www.google.com/"
    
    }
    //-->
    </script>
    This should go in the <body> </body>
    HTML Code:
    <input type="button" onclick="redirect()" value="Redirect">
    Keyboard1333
    Last edited by keyboard; 01-17-2012 at 08:25 AM.

  3. #3
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    689
    Thanks
    1
    Thanked 113 Times in 111 Posts

    Default

    Hi there juliememe,

    and a warm welcome to these forums.

    try it like this...
    Code:
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    
    <title></title>
    
    <style type="text/css">
    #mybutton {
        color:#000;
        text-decoration:none;
     }
    </style>
    
    </head>
    <body>
    
    <div>
     <a id="mybutton" href="http://www.google.com/" title="link to google.com">
      <button>google</button>
     </a>
    </div>
    
    </body>
    </html>
    
    coothead

  4. #4
    Join Date
    Sep 2010
    Location
    Hi Stalker.
    Posts
    148
    Thanks
    16
    Thanked 3 Times in 3 Posts

    Default

    Code:
    <a href="http://google.com/"><button>Your First Button</button></a>
    Or:
    Code:
    <button onclick="window.location='http://google.com';">Your First button</button>
    Daba! The Fantage-like website
    Virtual World in progress.
    Out of pure HTML, Javascript, and CSS. Oh, and poorly done Paint images.

  5. #5
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is your code:

    HTML Code:
    <form method="LINK" action="http://yourlink.com">
    <input type="submit" value="Button with link">
    </form>

    _________________________________________________________________

    A free escort website solution for both independent escorts and agencies.

  6. #6
    Join Date
    Jan 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    you can do it in various ways:

    Using the below source will allow you to create a push button link. change the URL http://www.yoursite.com to the web page you wish to open.
    Code:
    <FORM>
    <INPUT TYPE="BUTTON" VALUE="Home Page" ONCLICK="window.location.href='http://www.yoursite.com'"> 
    </FORM>
    other one is:
    remove spaces and carriage returns from code in quotes

    Code:
    <form>
    <input 
    type="button" 
    src="image-url" 
    onClick="Javascript: window.open( URL, "_self", , True)
    >
    OR
    
    onClick="Javascript: window. location. replace( URL )
    
    </form>
    A simple javascript can also fulfill your need:

    Code:
    function Hi()
    {
    alert("psst");
    }
    
    
    function addRowToTable()
    {
    var tbl = document.getElementById('secondtable');
    var lastRow = tbl.rows.length;
    // if there's no header row in the table, then iteration = lastRow + 1
    var iteration = lastRow;
    var row = tbl.insertRow(lastRow);
    var cell1 = row.insertCell(0);
    
    var buttonnode= document.createElement('input');
    buttonnode.setAttribute('type','button');
    buttonnode.setAttribute('name','sal');
    buttonnode.setAttribute('value','sal');
    cell1.appendChild(buttonnode);
    buttonnode.attachEvent('OnClick',Hi());
    
    }
    Complete code:

    Code:
    <html>
    <head><title></title>
    <script type="text/javascript" language="javascript">
    <!-- Hide from browsers without javascript
    
    function g()
    {
    	alert("you clicked?");
    	
    }
    
    window.onload=function()
    {
    	var buttonnode= document.createElement('input');
    	buttonnode.setAttribute('type','button');
    	buttonnode.setAttribute('name','button'+3);
    	buttonnode.setAttribute('value','sal');
    	buttonnode.setAttribute('onclick', function(){alert('Clicked')});
    	document.getElementsByTagName("body").item(0).appendChild(buttonnode);
    };
    
    // End hiding -->
    </script>
    </head>
    <body>
    
    <div>some text</div>
    
    </body>
    </html>
    Hope this serves your purpose.
    Thanks
    Last edited by djr33; 01-27-2012 at 08:54 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •