Solved

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

Posted on 2016-11-14
3
43 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 51

Expert Comment

by:Julian Hansen
Comment Utility
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 82

Accepted Solution

by:
leakim971 earned 500 total points
Comment Utility
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
Comment Utility
Thanks experts for your quick reply. It does work perfectly fine. Thanks you so much
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now