create an javascript alert before linking to a new php page
Moderator: General Moderators
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
create an javascript alert before linking to a new php page
I have a image button that links through to a new page but i need an alert to popup before the page is viewed but i am getting an error i have so far
<script type="text/javascript">
<!--
function navConfirm(loc) {
if (confirm('your have 72 to ours to query the document')) {
window.location.href = loc;
}
return false; // cancel the click event always
}
//-->
</script>
<a href="../admin/docs/<?php echo $row_Recordset1['Inventory']; ?>" onclick="return navConfirm(this.ref);" target="_new"><img src="../images/smalldownload.png" width="35" height="35" alt="download" /></a>
but when i run it i get the following error page
The requested file http://www.website.com/beta/signup-login/undefined does not exist on the web server, it may be a misspelling or perhaps it was removed in a website restructure.
thanks in advance
<script type="text/javascript">
<!--
function navConfirm(loc) {
if (confirm('your have 72 to ours to query the document')) {
window.location.href = loc;
}
return false; // cancel the click event always
}
//-->
</script>
<a href="../admin/docs/<?php echo $row_Recordset1['Inventory']; ?>" onclick="return navConfirm(this.ref);" target="_new"><img src="../images/smalldownload.png" width="35" height="35" alt="download" /></a>
but when i run it i get the following error page
The requested file http://www.website.com/beta/signup-login/undefined does not exist on the web server, it may be a misspelling or perhaps it was removed in a website restructure.
thanks in advance
Re: create an javascript alert before linking to a new php p
Check the onclick="return navConfirm(this.ref);"
Use "this.href"
Use "this.href"
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: create an javascript alert before linking to a new php p
I have tried it with using just a text link to a website
<a href="http://www.thiswebpage.com" onclick="return navConfirm(this.href);">This Webpage</a>
and that works fine. IM not sure what you mean Use "this.href"
thanks
<a href="http://www.thiswebpage.com" onclick="return navConfirm(this.href);">This Webpage</a>
and that works fine. IM not sure what you mean Use "this.href"
thanks
Re: create an javascript alert before linking to a new php p
You missed "h", while passing parameter in navConfirm() function, you have passed "this.ref", so I asked you to write it correctly
Checked the underline part of your code
<a href="../admin/docs/<?php echo $row_Recordset1['Inventory']; ?>" onclick="return navConfirm(this.ref);" target="_new"><img src="../images/smalldownload.png" width="35" height="35" alt="download" /></a>
You may have got what I mean to say...
Checked the underline part of your code
<a href="../admin/docs/<?php echo $row_Recordset1['Inventory']; ?>" onclick="return navConfirm(this.ref);" target="_new"><img src="../images/smalldownload.png" width="35" height="35" alt="download" /></a>
You may have got what I mean to say...
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: create an javascript alert before linking to a new php p
Oh yes, thanks for that, little slow today
thanks again
thanks again
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: create an javascript alert before linking to a new php p
yes except i woant it to appear in a new window
this is what i have
<a href="../hostadmin/docs/<?php echo $row_Recordset1['Inventory']; ?>" onclick="return navConfirm(this.href);" target="_new"><img src="../images/smalldownload.png" width="35" height="35" alt="download" />
thanks
this is what i have
<a href="../hostadmin/docs/<?php echo $row_Recordset1['Inventory']; ?>" onclick="return navConfirm(this.href);" target="_new"><img src="../images/smalldownload.png" width="35" height="35" alt="download" />
thanks
Re: create an javascript alert before linking to a new php p
Use target="_blank" instead of target="_new" in anchor tag
Re: create an javascript alert before linking to a new php p
I think it will not work as you are using javascript function to open the links. You need to use javascript window.open() function to open url in new window.
-
jonnyfortis
- Forum Contributor
- Posts: 462
- Joined: Tue Jan 10, 2012 6:05 am
Re: create an javascript alert before linking to a new php p
ok will leave at as it is thanks for your help