Solved

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

Posted on 2016-11-14
3
142 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 54

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 82

Accepted Solution

by:
leakim971 earned 500 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

808 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