Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

javascript window.createPopup() not working in chrome but works in IE browser

Posted on 2016-11-14
3
Medium Priority
?
726 Views
Last Modified: 2016-11-15
Hi Experts,

I am trying to call javascript function through .cs file by using following code but it does work fine in IE but not in chrome. if you see popup function in javascript , its second line does creat prob i.e.             var p = window.createPopup(); in chrome, Is there any way to overcome this ?

function popup() {
        
            alert('hi');
            var p = window.createPopup();
            alert('above mentioned line does not work in chrome browser');
            var pbody = p.document.body;
            var hdnPop = document.getElementById("<%= Panel1.ClientID %>");
            
        }
<ASP:Image ID="ContactImage" runat="server" ImageAlign="Middle" ImageUrl="~/images/folder_up.jpg"
                                AutoUpdateAfterCallBack="True" />

this.ContactImage.Attributes.Add("OnClientClick", "return popup();

Open in new window


Please suggest.
0
Comment
Question by:satmisha
3 Comments
 
LVL 60

Expert Comment

by:Julian Hansen
ID: 41886300
createPopup is IE specific and no longer supported please refer to this article https://msdn.microsoft.com/en-us/library/ms536392(v=vs.85).aspx

You will need to look at one of the jQuery / JavaScript libraries that provide this functionality - www.jqueryui.com is a good resource to start with.
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 41886392
Add a bit of code in your current javascript file :
if(!window.createPopup) {
	window.createPopup = function() {

	       var div = document.createElement("div");
	       div.style.position = "absolute";
	       div.style.top = "20px;"
	       div.style.left = "50%";
	       div.style.zIndex = "99999";

	       var iframe = document.createElement("iframe");
	       iframe.src = "about:blank";
	       iframe.style.position = "relative";
	       iframe.style.left = "-50%";

	       div.appendChild(iframe);

	       document.body.appendChild(div);

	       div.document = iframe.contentDocument;
	       return div;
	}	
}


function popup() {
        
            alert('hi');
            var p = window.createPopup();
            alert('above mentioned line SHOULD NOW work in chrome browser');
            var pbody = p.document.body;
            var hdnPop = document.getElementById("<%= Panel1.ClientID %>");
            
        }

Open in new window

0
 

Author Closing Comment

by:satmisha
ID: 41887753
Thanks experts for your quick reply. It does work perfectly fine. Thanks you so much
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question