Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How do i remove links from this onclick code

Featured Replies

hi all, ive just found this script and it works well! However i dont want the link function there so can someone please delete what needs deleting so it still works cause when i delete the link parts it stops working...

 

I only want to click a button and an image swops which is what it does. But this code also includes a onclick of the image it opens a URL and i need that part deleting from all images.. Its embeded in the Jscript..

 

any help will be greatly appreciated!

 

Cheers then

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>
<head xmlns="http://www.w3.org/1999/xhtml">
<title>Js Testing</title>
<style type="text/css">
button    {
   border: solid 1px #000000;
   text-decoration:none;
   color:#000000;
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 10px;
   font-style: normal;
   font-weight: normal;
   font-variant: normal;
   padding:4px;
   background-color:#99FF66;
   float:left;
   margin-left:5px;
   margin-top:10px;
}
button:hover    {
   border: solid 1px #333333;
   text-decoration:none;
   font-family: Verdana, Arial, Helvetica, sans-serif;
   font-size: 10px;
   font-style: normal;
   font-weight: normal;
   font-variant: normal;
   padding:4px;
   background-color:#00CC33;
   float:left;
   margin-left:5px;
   margin-top:10px;
}
</style>
</head>
<body>
<div id="header">
<h1>Javascript Testing</h1>
</div>
<script type="text/javascript">17.18

/*Image data: src, link */
var data = [
   {src: "images/random2.jpg", link: "http://google.com"},
    {src: "images/random3.jpg", link: "http://yahoo.com"},
	    {src: "images/random4.jpg", link: "http://chapo.co.cc"}
	    ];
	    /* This function will be called when button is clicked.*/
	    function buttonclick(index) {
		    if(!data[index]) {
				    alert("No data found at index : " + index);
						    return;
							    }
								    var src = data[index].src;    var link = data[index].link;
					    var img = document.images.im1;
							    /* Changing image attributes */
								    img.src = src;    img.onclick = function() {	    window.open(link);
									    };}
									    </script>
									    <div>
									    <img src="images/random1.jpg" name="im1" onclick="window.open('http://google.com')"/><br/>
									    <button onclick="buttonclick(0);">1</button>
									    <button onclick="buttonclick(1);">2</button>
									    <button onclick="buttonclick(2);">3</button>
									    </div>
									    </body>
									    </html>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.