JavaScript pop-up, can't change URL - javascript

So I've been experiencing several issues around pop-up windows within a corporate Intranet site, i.e. JavaScript 'window.open' the last one brought to my attention is the inability to change the URL of a pop-up once it's opened. I first tried this on Edge then Firefox to confirm.
After playing with the pop-up window options, I found that if I set 'toolbar=1' then I could change the URL in Firefox but not Edge or IE.
I was using the following code in a w3schools editor
<!DOCTYPE html>
<html>
<body>
<p>Click the button to open a new browser window.</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
window.open('https://www.w3schools.com','123','width=560,height=340,toolbar=1');
}
</script>
</body>
</html>
This seems to be a Windows 7 and 10 issue on IE or Edge. Is there a new security setting somewhere that I'm missing?

Related

iOS Chrome App is printing entire page instead of an iframe

Problem
I am unable to print only the contents of my iframe in the iOS Google Chrome app. It is printing the entire screen instead of only the contents in the iframe.
I have added a snippet of code in here for reference - https://jsfiddle.net/doominer/jwhzpstk/12/
<!-- index.html -->
<html>
<body>
<iframe src="jsfiddle.net" height="200" width="300" id="frame" title="Iframe Example"></iframe>
<button onclick="print()">
Print
</button>
</body>
</html>
// script.js
function print(){
printFrame("frame")
console.log("hi")
}
function printFrame(id) {
var frm = document.getElementById(id).contentWindow;
frm.focus();// focus on contentWindow is needed on some ie versions
frm.print();
return false;
}
My iOS Google Chrome app version is 106.0.5249.92
Steps to recreate the issue:
Open https://jsfiddle.net/doominer/jwhzpstk/12/ on your iPhone's Google Chrome app (I am using iphone 11 pro; this also happens on my ipad air. )
Click on the "print" button on the screen
You should see that the entire screen gets printed instead of the iframe (this is the issue)
Try this on iPhone Safari and Safari will print the iframe instead (intended behavior)
I have also logged this in the google support site for additional support, if anyone is interested.

window.close not closing window in HTA application

In my HTA application I'm using a JavaScript calendar window, it opens using window.open() and closed using window.close(), when the user clicks on one of the dates. This calendar works fine on multiple browsers and versions over more than 10 years. It even works in HTA applications most of the time.
However on specific workstations running IE11. The window.close() command is simply ignored, resulting in the window left open. On other IE11 workstations it works fine. I figured that turning off the "Enable Protected Mode" checkbox on IE11, Internet Options, Security tab resolves the problem on one of the problematic workstation. However, other workstations works fine with this setting turned on and turning off this setting is not an acceptable solution.
Code sample which reproduces the problem:
HTA application
<HTML>
<HEAD>
<HTA:APPLICATION ID="OpenCloseExample" BORDER="thick" BORDERSTYLE="complex"/>
<TITLE>Open Close HTA container</TITLE>
</HEAD>
<iframe width="1024px" height="768px" src="http://localhost:28080/openclose.html"/>
</HTML>
openclose.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Main Page</title>
<script src="openclose.js"></script>
</head>
<body>
open
</body>
</html>
openclose.js
var win;
function openWindow() {
win = window.open("", "_blank", 'width=250,height=250,status=no,resizable=no,location=no,top=100,left=100');
win.document.writeln("<html><head><script src='openclose.js'></script></head><a href='#' onclick='javascript:window.opener.closeWindow()'>close</a></html>");
}
function closeWindow() {
win.window.close();
}
I can't see this working in any IE with any settings. The problem is this string: <script src='openclose.js'></script>. That is, a literal ending script tag in a string works as an ending script tag on a page, when HTML parser will find it. This means, that your script was never loaded.
To fix this, you've to break the literal tag, for example like so:
<script src='openclose.js'><\/script>
Since you have pointed out that IE11 is causing the JS not to work, you can force IE to render in an older version very easily.
<meta http-equiv="X-UA-Compatible" content="IE=9">
This meta tag is very popular amongst HTA applications for utilizing JS/ActiveX methods/properties within specific IE versions (most of them being deprecated).
For more information, visit the X-UA-Compatible Tag Wiki
Hope this helps
I figured this out eventually.
Changing:
open
to:
open
Has resolved the problem

AddThis on iPad

I have this AddThis:
<a class="addthis_button addthis_default_style">Share Site</a>
<script type="text/javascript" src="http://s7.addthis.com/js/300/addthis_widget.js#pubid=myid">
</script>
Looking good everywhere ...When clicked, I get the modal box/pop box with my sharing links...but when I click on iPad nothing happens...anyone know how to get this resolve?
Here's what I get running that code in the iPad simulator: http://i.imgur.com/4dYXnYw.png
Can you point me to a URL where you're running this code? The issue might be with how our code interacts with other elements on your page.

window.open(url) fails to download the pdf file

I am trying to open a URL, which points to a PDF, using window.open(url). In IE, the popup window flashes and nothing happens afterwords. When I access the same url directly using IE, PDF opens up perfectly.
In the HTML below, when I click on Link, I get the PDF but window.open fails. Moreover, if I provide a direct link of PDF in window.open that also works perfectly. Could any body shed some light on this?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
Link
<script>
url = "http://phx.corporate-ir.net/External.File?item=UGFyZW50SUQ9NDk2Mjl8Q2hpbGRJRD0tMXxUeXBlPTM=&t=1";
window.open(url);
</script>
</BODY>
</HTML>
Thanks
Most browsers block window.open when is called without user interaction in order to avoid popup advertisements.
Why are doing this anyway? Instead you should link directly to the PDF in the original document, where you can use target="_blank" if it must be in a new window. (Keep in mind, that there are users that don't like it if websites open new windows).
This may just be my convention, but I always use window.open() like this:
var win = window.open(url);

Keystroke working in IE not in Firefox

I am just trying a simple application, to make the browser fullscreen. this is working for Internet Explorer, but not for firefox.
Also I want to know, that can the same thing be done in Mac OC? do i have to make changes for Mac OS (using safari, firefox etc)
the code it below.
<html>
<head>
<script type="text/javascript">
function fullScreen()
{
var obj = new ActiveXObject("Wscript.shell");
obj.SendKeys("{F11}");
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" onclick="fullScreen()" />
</form>
<p>By pressing the button above, a function will be called. The function will alert a message.</p>
</body>
</html>
Regards
Zeeshan
All modern browsers, including IE8, allow the user to disallow a script's opening, moving or resizing a window. Also, IE allows you to prohibit activeX from untrusted (internet) sites,
and the other browsers don't have native activeX. so your solution may have very few successes, and a lot of errors and security warnings.
Of course, users can press f-11 anytime- maybe you could suggest they do so.
I believe ActiveXObject is IE specific so it will never work on FF.

Categories

Resources