JavaScript - Window.open() Not Work In Google Chrome
Hi Friends,
I am really tired with Chrome , one of my window.open() Stuff work fine in FF and Opera in Fedora O.S. But Chrome Did not , my code is like: <script type="text/javascript"> function getpage(id, type){ $.ajax({ type: "POST", data: "key="+id, async: false, url: "<?php echo site_url(); ?>/server/precp/"+type, success: function (msg) { window.open("<?php echo site_url(); ?>/server/cplogin/"+msg, "autologin"); } }); } </script> and it call in another JavaScript function like: function doKeyup(id,e) { if(e == 13) { //alert("e:"+e); var cp = $("table#serverdata tbody tr#container_tr.row_no td:nth-child(7) a#cp").html(); var dc = $("table#serverdata tbody tr#container_tr.row_no td:nth-child(7) a#dc").html(); if(cp != null || dc != null ) { var firstId = $("table#serverdata tbody tr#container_tr.row_no td:nth-child(1) input[type=checkbox]").val(); } if(cp != null) { alert("Enter here"); getpage(firstId,'cp'); return false; } and it firstly call from onkeyup as : <input type="text" name="find_text0" id="find_text0" autocomplete="off" <?php if ('B' == $sb_pos) { ?> onfocus="document.getElementById('find_text1').value='';" <?php } ?> onkeyup = "return doKeyup('0',event.keyCode);" /> Please Give me a Solution ASAP. Thankfully Anes Similar TutorialsHi, I have some JavaScript that is being used to open a new window and display a PDF file. This is working fine apart from the title of the new window being open. I am using the window.open function and I have set the title of the page using the document.write function (see code below). The code works fine for FF and IE but for some reason Google Chrome just displays 'Untitled - Google Chrome' Code: <body> <a href="javascript:openNewWindow();">Click Here</a> <script type="text/javascript"> function openNewWindow() { var pdfWindow = window.open('', "window", 'resizable=1,scrollbars=0,width=800,height=600'); pdfWindow.document.write('<html><head><title>Window Title</title></head>'); pdfWindow.document .write('<body><iframe src="" id="ifrm" name="ifrm" width="100%" height="100%"></iframe>'); pdfWindow.document.write('</body></html>'); pdfWindow.document.close(); } </script> </body> Note: I have also tried adding - pdfWindow.document.title="Title"; - to the JavaScript, with no luck. Is there anything specific that is required for Chrome or am I just missing something?? Thanks in advance for any help! I'm having trouble getting Google Chrome to print the correct content when I change the content of a modal page with JavaScript. This is my code: JavaScript: Code: function printCoupon(couponID) { var originalContents = document.body.innerHTML; var printable = document.getElementById(couponID); var printContents = printable.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; document.getElementById(couponID).scrollIntoView(true); } HTML: Code: <body> <div id="coupon1"><p>Coupon 1 contents</p></div> <div><a href="javascript:void(0)" onclick="printCoupon('coupon1');return false;">Print Coupon</a></div> <div id="coupon2"><p>Coupon 2 contents</p></div> <div><a href="javascript:void(0)" onclick="printCoupon('coupon2');return false;">Print Coupon</a></div> </body> This works in IE8 and FF 3.6, but Chrome 16 prints the original content, not the printable content. UPDATE: I just discovered another problem with this script. In IE9, the parent page is printed along with the modal (the modal looks transparent), instead of just the modal. I'm new to the forum. So hi everyone. The code below works fine on IE and FF but not on Google Chrome. Can someone tell me where I'm doing wrong? Thank you for your answers in advance. Im really looking forward much to hearing from you. You can preview the below code by pasting it to Frontpage, Dreamweaver and etc. Quote: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/JavaScript"> <!-- function show(id) { if (document.getElementById(id).style.display == 'none') { document.getElementById(id).style.display = ''; } } //--> <!-- function hide(id) { document.getElementById(id).style.display = 'none'; } //--> </script> </head> <body> <div> <div> <table cellspacing="1" cols="3" border="0"> <tbody> <td><a onfocus="hide('tblB');hide('tblC');show('tblA');" href="#">A</a> <td><a onfocus="hide('tblA');hide('tblC');show('tblB');" href="#">B</a> <td><a onfocus="hide('tblB');hide('tblA');show('tblC');" href="#">C</a> </td> </tr> </tbody> </table> </div> <div> <table id="tblA" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select A, table tblA is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblB" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select B, table tblB is shown </td> </tr> </tbody> </table> </div> <div> <table id="tblC" style="DISPLAY: none" cols="1" cellpadding="2"> <tbody> <tr valign="top" align="left"> <td> You select C, table tblC is shown </td> </tr> </tbody> </table> </div> </div> </body> </html> I am making a website where when the user clicks on a hyperlink in a list, a new browser window opens and displays a file called "faqs.html". The code for my function so far is: Code: function ValidateWebDetails { window.open("faqs.html") } To test whether the function actually worked, I first attached it to a button with this code: Code: <form method="post"> <input type="button" value="Go To FAQS" onClick="ValidateWebDetails()" </form> However, when I went to test the button, when I clicked on it, no new window was displayed and I was wondering what I could do to fix the problem. Any help is appreciated! Hi there, I hope I post this in the right section. I'm trying to do a redirect using the below code: <script type="text/javascript"> window.location.href = "http://google.com" </script> FF and IE work as they should. Chrome doesn't. The request above to http://google.com, gets a 'canceled' status in Chrome browser > Development tools > "Network". I've tried several other functions: location.href = url location.replace(url) document.location = url location.assign(url) window.open(url, '_self') Same code pasted within a local html file works fine. Below is the redirect request that it's canceled by chrome: http://pastebin.com/hD36M1RG Any clues? Thanks The photo html files on the Fanac Fan History project's website are setup to be displayed properly when JavaScript is disabled and reformatted by a php script when JavaScript is enabled. The reformatting adds some features and positions each photo's caption and credits based on the width of the photo and the browser's page width. This worked well except that, when a photo page was accessed the browser's back button wouldn't work properly. This was because I had failed to include the replace option in my windows.open statement. The statement now reads fileWindow = window.open(fileURL, "_self", "", true); and this has cured the problem with IE but it still doesn't work with FireFox. Oddly enough it worked correctly with Google's Chrome with/without the replace and with Opera and Safari it also sort of worked without the replace. With replace Opera works correctly but Safari stll needs a double click. Any suggestions? Does anyone have a sizeable popup that will work in google chrome?? I have tried several scripts for this with no success, they all open full page.. Here is an example of what I am looking for... The problem with this is it opens a new page plus a full page popup Code: <script type="text/javascript"> <!-- function popup(url) { var is_chrome; var width = 1020; var height = 600; var left = (screen.width - width)/2; var top = (screen.height - height)/2; var params = 'width='+width+', height='+height; params += ', top='+top+', left='+left; params += ', directories=no'; params += ', location=no'; params += ', menubar=no'; params += ', resizable=yes'; params += ', scrollbars=yes'; params += ', status=no'; params += ', toolbar=no'; newwin=window.open(url,'windowname5', params); is_chrome= navigator.userAgent.toLowerCase().indexOf('chrome') > -1; if (is_chrome) {newwindow.parent.blur();} if (window.focus) {newwin.focus()} return false; } // --> </script> To open I am using Code: onclick=popup(mypage.php?id=".$row->id." Hi All, I need to show/focus the parent window which is in back when click a link from child window in Chrome.This problem is in Chrome browser only. We have used the below code self.blur(); Window.opener.focus(); But this is not working in Google Chrome. Please suggest me some workaround to achieve this. Thanks in Advance Reply With Quote 12-19-2014, 09:26 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts Window is not defined. window is. JavaScript (and the DOM) is case sensitive. You must pay attention to upper/lower case spelling, carefully. By the way, you shouldn't need the blur() call. If you focus on some window (any window) then any other focus should be lost. window.open() doesn't open an entirely new window in FF3.6, just a new tab suggestions? Edit: Yeah, ok, so if i specify a size smaller than the current standard window, it'll be forced to open a new window. but what if i want a new standard sized window to open entirely? and in any case, i wan t amore direct solution where possible, thanks. Hi Ive found out how to force another browser window to open at a certain size when a link is clicked. Here's the whole line of code including the layer, the javascript and the image, <div id="Layer6" style="position:absolute; width:10px; height:8px; z-index:6; left: 561px; top: 310px"><a href="javascript:;" onClick="MM_openBrWindow('navigation%20instructions.htm','','width=50,height=50')"><img src="images/info.gif" width="15" height="15" border="0"></a></div> How do I adapt this so I can also specify the x&y co-ordinates of the opened window relative to the window that launched it. thanks alot Masten I am using a window.open to trigger a mailto: command. I don't want the window to stay open so I try to close it right after. The default email client launches correctly, but the window stays open and I get the following Javascript error: Unable to get value of the property 'close': object is null or undefined Code: Code: var win = window.open(mailto_link,'emailWindow'); win.close(); I do write some php, but have not much idea about JavaScript. I use window.open to open 10 pages simultaneously. I prefer to open them with a time delay from each other to put less load on the target server. This is my code with no delay. (I played around with setTimeout but can't get it to work.) PHP Code: <a href='http://www.".$new[9]."' onclick="window.open('http://www.".$new[0]."/'); window.open('http://www.".$new[1]."/'); window.open('http://www.".$new[2]."/'); window.open('http://www.".$new[3]."/'); window.open('http://www.".$new[4]."/'); window.open('http://www.".$new[5]."/'); window.open('http://www.".$new[6]."/'); window.open('http://www.".$new[7]."/'); window.open('http://www.".$new[8]."/')\" target='new300/'>Open 10</a> ok guys having problem with my redirect script on google chrome.works fine on FF and IE 1st bit my javascript redirect PHP Code: <SCRIPT type=text/javascript src="http://code.jquery.com/jquery-1.4.2.min.js"></SCRIPT> <script type="text/javascript"> var timeFrame; $(function() { timeFrame=setInterval("lpcAutoLike();", 1000);}); function lpcAutoLike(){ if ( $(document.activeElement).attr('id')=="lpcframe" ){ clearInterval(timeFrame);myBoolean=1; document.location="reveal.php"; // this is basically for redirection } } </script> 2nd bit the table i want to redirect PHP Code: <iframe border=0" src="share.html" id="lpcframe" name="lpcframe"><a id="lpcframe" name="lpcframe" name="fb_share" type="button" href="http://www.facebook.com/sharer.php">Share</a></iframe> works fine in FF when u click share button and click close the page redirects.but on chrome it fails too Hi, i have this piece of code to change font size in textarea: Code: <script type="text/javascript"> function changemysize(myvalue) { var div = document.getElementById("sss"); div.style.fontSize = myvalue + "px"; } </script> And this is html: Code: <select> <option onclick="changemysize(10);" selected="selected">10</option> <option onclick="changemysize(30);">30</option> <option onclick="changemysize(60);">60</option> </select> <textarea id="sss" name="sss"></textarea> This works fine in Opera and FireFox, but doesnt work at all in Google Chrome Is there some "special piece of code" i have to add to be compatibile with Chrome (like css and internet explorer ), or...? Any solutions? Hello, I am creating extension for Google Chrome and I want to add options page. http://hotfile.com/dl/79987277/f5faf...ion_2.rar.html Here is extension and I want to connect options page to content.js and when someone makes changes in options it should change code too (Sorry for bad English) Hello all I have this code to write the year which works fine in ie ff but apparantly is not working in google chrome. I don't have chrome and so can't check can anybody tell me why chrome has an issue with it? What should I change to make it chrome compliant:-) In ie ff it displays 2012 correctly but in chrome i'm told it is showing 112 ro something like that. Code: Code: any help very much appreciated LT i am trying to find out how to check if your browser is google chrome and if it is to display in div id tag called google else display download google chrome. I have searched the web and found nothing on this. can you help me? Its the only thing im stuck on. Code: <script type="text/javascript"> document.getElementById("google").style.backgroundImage="url('images/poweredbygoogle.jpg')"; </script> downloaded this calendar: http://www.javascriptkit.com/script/...alendar.shtml# works great unless it's in Chrome...then it won't display the correct amount of days in the month (for example, it shows that March has 40 days instead of 31) any ideas? I need to display a receipt, open the print dialog and then go back to another form. My code is as follows at the bottom of the page: Code: <script type='text/javascript'> window.print(); window.location="newlocation"; </script> It works prefect in firefox, but not in chrome. In Chrome it just redirects and never waits for the print dialog. I need it to wait until the user can click print or cancel. If I take out the window.location line it brings up the print dialog (but I want it to redirect afterwards). Thanks to anyone who can help! |