document.open does not work in Safari - javascript

I have the following javascript code, I tried to test it in Chrome, Firefox and Opera, they all working fine, but on Safari, it generates error "undefined is not an object (evaluating 'x.document')", any idea on how to resolve it? Thanks.
var x = window.open();
x.document.open();
x.document.write('hello world');
x.document.close();

You need to enable popup windows in Safari. Go to Preferences > Security > Block pop-up windows for this to work in Safari. Otherwise, Safari does not allow you to reference a document within a blocked window.

Related

showModal() on dialog element doesnt work for Safari but does for Chrome

Im having some issues presenting a modal on Safari. This currently works in Chrome:
var screenShotDialog = document.createElement("DIALOG");
document.getElementsByTagName("BODY")[0].appendChild(screenShotDialog);
screenShotDialog.showModal();
however, when i try to run this same server on Safari, this showModal() method is appending this dialog to the bottom of my page, while in Chrome it shows it as a "popup". Checking the console logs, im getting
screenShotDialog.showModal is not a function. (In
'screenShotDialog.showModal()', 'screenShotDialog.showModal' is
undefined)
I dont get this error in chrome, looking at the dialog documentation here http://www.w3schools.com/jsref/met_dialog_showmodal.asp I see that this should be supported for Safari ( i have Safari Version 9.0.3 ). Can anyone help this is pretty frustrating.

How can I open new window of Safari by JavaScript Automation when Safari is running and has no windows?

When Safari is not running, I can open Safari by the following Automation JavaScript code.
safari = Application('Safari')
But when Safari is running and has no windows, the above code does not open Safari's new window.
I tried to add the following code.
window = safari.Window()
safari.windows.push(window)
But no effects.
How can I open new window of Safari by JavaScript Automation when Safari is running but has no windows?
Currently, I am using the following code
safari = Application('Safari')
safari.open(Path('~/dummy'))
I do not like it.
You just need Document, not Window.
Safari = Application('Safari');
Safari.Document().make();

Change the context of the Safari 6 console to an iframe on the page

I know that Chrome let's you pick the context for the console's execution with a dropdown menu and that Firebug let's you cd() into an iframe. I can't figure out how to change the context in Safari's console. Does anyone know how to do this?
Safari, unlike chrome and firefox, has no real support for this functionality and the only option seems to be to access the window object from the console. As you correctly point this will trigger cross domain policy issues, however provided you're running on mac (this does not work for some reason on windows) you can use
open -a '/Applications/Safari.app' --args --disable-web-security
to bypass this. And next on your jsbin you could use something along the lines of
window.frames[0]
to access the window of the page. As far as I can see there is no similar solution for windows, as
Safari.exe --disable-web-security
apparantly does not work.
The Iframe element itself is of Type Window within Console
<iframe id="frame" src="about:blank"/>
In Safari console then you simply work with
frame.document.write('bla');
please notice that 'frame' is shorthand for document.getElementById('frame')

IE Chrome Frame Full Screen

I have a working implementation of full screen working for Safari, Firefox, and Google Chrome. From what I have read it should work for ie with google chrome frame but when I click the full screen button I created nothing happens. Any ideas? Is it not yet supported?
$('#enable_fullscreen').click ->
calculate_presentation_font_size(height)
if docElm.requestFullscreen
docElm.requestFullscreen()
else if docElm.mozRequestFullScreen
docElm.mozRequestFullScreen()
else if docElm.webkitRequestFullScreen
docElm.webkitRequestFullScreen()
Putting an alert in the "webkitRequestFullScreen" if statement shows that it does go to this condition in chrome frame but docElem.webkitrequestFullScreen() is undefined.
I've build it and made it work from this examples.
https://developer.mozilla.org/en-US/docs/DOM/Using_full-screen_mode
The only things I can see missing from your code for the webkit condition is the parameter "Element.ALLOW_KEYBOARD_INPUT" to the webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)
Unfortunately the main problem of chrome frame is the communication with the IE window that literally behave like a difficult child ;-)
For IE you can open a popup window in fullscreen mode by directly calling document.location.href for the source it will open the current page your are on
window.open(document.location.href, 'myAppfullscreen', 'fullscreen=1');

New Window in GWT, DOM, Internet explorer

I'm trying to create new Window with GWT as it shown here: https://stackoverflow.com/a/4205058/898588
This works in FF, Chrome, but doesn't work in IE (IE9 in my case). I see exception in dev. mode:
(null): DOM Exception: HIERARCHY_REQUEST_ERR (3)
So, this string:
bdElement.getOwnerDocument().getElementById("mainbody").appendChild(config.getElement());
throws this exception.
I've tried:
bdElement.appendChild(config.getElement());
but it was unsuccessfully.
How to make it work in IE?
Solution was found:
bdElement.getFirstChildElement().setInnerHTML(config.getElement().getString());
This works in IE, Opera, Chrome, FF
To be more specific, you only need to use setInnerHTML() instead of appendChild(), so the following piece of code will work as well in IE9 and Chrome as far as I can tell:
bdElement.getOwnerDocument().getElementById("mainbody").setInnerHTML(config.getElement().getString());

Categories