Solved

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

Posted on 2016-11-14
3
332 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 57

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article discusses how to implement server side field validation and display customized error messages to the client.
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

759 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