Hello when I click on "click here" , it should open up a new window. I am not sure why this is not working. However if I remove the javascript part, the href takes me to the new page, on the same ie window.
The link is all fine, it's just that I am unable to open a new window with the link. Kindly help with syntax to correct my javascript function.
You dont need to write javascript for opening page in another browser instance. Just give target property as "_blank" just like below. by default its "_self".
<a href="http://www.google.co.in" runat="server" target="_blank">Click here to google</a>
urpalshu
Member
50 Points
254 Posts
open a new window using javascript or jquery
May 04, 2010 07:46 PM|LINK
divtutor.InnerHtml = "<div id='output' style=' color: Black; position: absolute;width: 360px; height:100px;'>" + "<table style='background-color: #808080;border: 1px solid #646464;color: white; width: 360px; height:100px; '>" + "<tr ><td colspan='3'>" + "<table width='100%'><div style='text-align: right;' class='close'><img src='../../images/icon/close.jpg' /></div>" + "<tr ><td></td></tr>" + "</table>" + "</td></tr>" + "<tr ><td ><a style='color:White; padding-left: 25px;' href='JavaScript:newPopup('" + ConfigurationManager.AppSettings["HelpPageURL"] + "/RSystem/htm/tutor/invoice.swf');'>Click here</a></td></tr>" + "</table>" + "</div>"; ASPX PAGE <script type="text/javascript"> // Popup window code function newPopup(url) { alert(url); popupWindow = window.open( url, 'popUpWindow', 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes') } </script> <div runat="server" id="divtutor"></div>Hello when I click on "click here" , it should open up a new window. I am not sure why this is not working. However if I remove the javascript part, the href takes me to the new page, on the same ie window.
The link is all fine, it's just that I am unable to open a new window with the link. Kindly help with syntax to correct my javascript function.
Thanks
mellamokb
Contributor
4061 Points
724 Posts
Re: open a new window using javascript or jquery
May 05, 2010 03:39 AM|LINK
Hi urpalshu,
It looks like your problem is the nested single quotes:
"<tr ><td ><a style='color:White; padding-lef: 25px;' href=\"JavaScript:newPopup('" + ...Notice the replacement of href=' to href=\". You'll need to do that to other side as well, i.e., /htm/tutor/invoice.swf');\">.
Hope this helps!
Regards,
~ mellamokb
Naved Hasan ...
Participant
1005 Points
212 Posts
Re: open a new window using javascript or jquery
May 05, 2010 04:40 AM|LINK
hello
The problem lies in 'url', see what link u are getting in alert(url), paste that link in the address bar and check if this is the page u want.
Try using a label, assign the url value in the label and then call the newPopup() function, that would be clearer to do.
sandy060583
Star
8714 Points
1624 Posts
Re: open a new window using javascript or jquery
May 05, 2010 05:09 AM|LINK
HTML:
<a href="http://www.google.com" rel="external">Google</a>
Javascript:
$(document).ready(function() {
$("a[rel=external]").attr('target', '_blank');
});
Or
$(document).ready(function() {
$('a[rel="external"]').click( function() {
window.open( $(this).attr('href') );
return false;
});
});
more :
http://www.aliaspooryorik.com/blog/index.cfm/e/posts.details/post/use-jquery-to-make-external-links-open-in-a-new-window-94
Ramani Sandeep (My Blog)
(MCTS, MCC-2011)
Das.Sandeep
Star
10652 Points
1897 Posts
Re: open a new window using javascript or jquery
May 05, 2010 05:24 AM|LINK
http://snipplr.com/view/8733/jquery-open-external-link-in-new-window/
Please give us feedback no matter whether you get your answer.
Please "Mark as Answer" if it's useful for you.
Regards,
Sandeep
A1ien51
All-Star
29935 Points
5821 Posts
Re: open a new window using javascript or jquery
May 05, 2010 11:28 AM|LINK
Joshi Amit
Member
616 Points
93 Posts
Re: open a new window using javascript or jquery
May 05, 2010 11:34 AM|LINK
I see SemiColon Missing at the end of this statement, please try putting a semicolon at the end of this statement.
popupWindow = window.open( url, 'popUpWindow', 'height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no,status=yes')
http://amitjoshi1980.blogspot.com/
- Helping others helps me to learn more.
Dj.
Participant
847 Points
149 Posts
Re: open a new window using javascript or jquery
May 05, 2010 11:35 AM|LINK
You dont need to write javascript for opening page in another browser instance. Just give target property as "_blank" just like below. by default its "_self".
<a href="http://www.google.co.in" runat="server" target="_blank">Click here to google</a>
|Dj|