Solved

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

Posted on 2016-11-14
3
451 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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

630 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