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.

<input type="button" onClick Question.

Featured Replies

Hey guys,

quick Q.

 

Creating a small script for downloading, just for experience, and i have this code right now:

 

<title>Download</title>
<body>
Download Example.rar by clicking the download button.<br />

<input type="button" OnClick="location.href='Example.rar'";"
else
OnClick="location.href='temp.txt'";"  value="Download">

 

I was wondering if you could combine the OnClick's and create 2 scripts?

So, onClick="location.href='google.com';" and then run onClick="location.href='Example.rar';"

 

I've seen this done before on other site, just wondered if it was as simple as on onClick, and how to do it?

 

Regards,

 

EDIT ::

 

Forgot to add,

Where onClick="location.href='google.com';", i wanted that was a popup. Forgot to add that in xD

Assign to onclick some twoClickFunction(). This function, being activated through click, will check some variable, say, Flag (by default Flag=0;). If Flag=0, {1st action is executing and Flal=0}; else {2nd action; Flag=1;}. Simple switch.

Something like that.

  • Author

Sorry mate, im abit useless and i dont understand :S

 

Could you explain it abit simpler please? :)

 

Regards,

As for me 'abit simplier' means to write code, properly speaking:

<script language="JavaScript">
Flag = 0;
function popup() {
window.open ("http://google.com","mywindow","menubar=1,resizable=1,width=350,height=250");
}

function twoClixFunction() {
var d = new Date();
var time = d.getHours();

if (Flag == 0) {
	popup();
	Flag=1;
	f.butt.value = 'Click Me for new location';
	}
else
	{
	location.href='http://yahoo.com';
	Flag=0;
	f.butt.value = 'Click me for popup';
}
}
</script>
<form name="f">
<input type="Button" name="butt" onclick="twoClixFunction()" value="Click me for popup" />
</form>

  • Author

Thanks, works to some degree.

 

Was hoping that the user would have to click twice, so literally speaking =

 

Page > Clicks button > Popup > then file for download.

 

Instead of Page > clicks button > popup > clicks button > file download...

 

If that makes sense?

Do I correctly understand that you want to assign two consecutive events to the single click? If yes, it is very easy.

<script language="Javascript">
function popup() {
window.open ("http://google.com","mywindow","menubar=1,resizable=1,width=350,height=250");
}


function loadfile() {
location.href='http://www.webdesignerforum.co.uk/uploads/av-16198.jpg';
}
</script>
<form name="f">
<input type="Button" name="butt" onclick="popup(); loadfile()" value="Click me for popup AND load file" />
</form>

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.