Try onclick function separately it can give you access to execute your function which can be used to open up a new window, for this purpose you first need to create a javascript function there you can define it and in your anchor tag you just need to call your function.
Step 1: Firstly, we have to type the script tag between the starting and closing of <head> tag just after the title tag. And then, type the JavaScript function. Step 2: After then, we have to call the javaScript function in the Html code for displaying the information or data on the web page.
It is safe to click on that link with # href; the page does leave/reload url. Follow the above advice with caution, as HTML5 rules explicitly state that href="#" is supposed to navigate to the top of the page. You can simply add the href attibute without content, and get the click behaviour.
A href JavaScript function call | Example code Simple use javascript:void(0) as the value of href and onclick method function name to call JavaScript function. Or another way is to use javascript:method_name as the value of href.
Try onclick function separately it can give you access to execute your function which can be used to open up a new window, for this purpose you first need to create a javascript function there you can define it and in your anchor tag you just need to call your function.
Example:
function newwin() {
myWindow=window.open('lead_data.php?leadid=1','myWin','width=400,height=650')
}
See how to call it from your anchor tag
<a onclick='newwin()'>Anchor</a>
Visit this jsbin
http://jsbin.com/icUTUjI/1/edit
May be this will help you a lot to understand your problem.
Fun! There are a few things to tease out here:
$leadID
seems to be a php string. Make sure it gets printed in the right place. Also be aware of all the risks involved in passing your own strings around, like cross-site scripting and SQL injection vulnerabilities. There’s really no excuse for having Internet-facing production code not running on a solid framework."
or '
characters. Since you’re already inside both "
and '
, you’ll want to escape whichever you choose. \'
to escape the PHP quotes, or '
to escape the HTML quotes.<a />
elements are commonly used for “hyper”links, and almost always with a href
attribute to indicate their destination, like this: <a href="http://www.google.com">Google homepage</a>
.return false;
to a Javascript event to suppress default behavior.onclick
doesn’t mean anything on its own. That’s because onclick
is a property, and not a variable. There has to be a reference to some object, so it knows whose onclick
we’re talking about! One such object is window
. You could write <a href="javascript:window.onclick = location.reload;">Activate me to reload when anything is clicked</a>
.onclick
can mean something on its own, as long as its part of an HTML tag: <a href="#" onclick="location.reload(); return false;">
. I bet you had this in mind.=
assignments. The Javascript =
expects something that hasn’t been run yet. You can wrap things in a function
block to signal code that should be run later, if you want to specify some arguments now (like I didn’t above with reload
): <a href="javascript:window.onclick = function () { window.open( ... ) };"> ...
.<a href="http://www.google.com" target="_blank">Google homepage</a>
.Hope those are useful.
You should read up on the onclick
html attribute and the window.open()
documentation. Below is what you want.
<a href='#' onclick='window.open("http://www.google.com", "myWin", "scrollbars=yes,width=400,height=650"); return false;'>1</a>
JSFiddle: http://jsfiddle.net/TBcVN/
Use the onclick
as an attribute of your a
, not part of the href
<a onclick='window.open("lead_data.php?leadid=1", myWin, scrollbars=yes, width=400, height=650);'>1</a>
Fiddle: http://jsfiddle.net/Wt5La/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With