I've been using the following script for a few years now to navigate to the users home page when a button is clicked. However, with the start of IE8, this does not work as it appears "about:home" is no longer valid.
if(window.home) {
// for everything but IE:
window.home();
} else {
// for IE:
window.location = "about:home"; // IE8 will error here if the location is "about:home"
}
Is there a new way of getting Internet Explorer 8+ to navigate to the users home page? The script must be cross browser.
The URI to be navigated to when about:home is entered in the location bar is stored in the Registry under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\AboutURLs
However, this feature seems to be disabled for IE8. The entry Home is a REG_DWORD and not a string value containing the URL of the home page. This might be related to the feature of having several home pages that can be opened in tabs.
I wasn't able to find any documentation on the meaning of the Home REG_DWORD value though but it is possible to change it to a string value. Then about:home will navigate to the URL specified in that value. However, this is most likely not a solution for you as this requires admin permissions for the registry.
I figured it out, though the resolution seems very strange to me:
Create a new CSS element:
.hpClass { behavior:url(#default#homepage) }
Create a span referencing the new CSS & creating a class name:
<span id="hp" class="hpClass"></span>
Wrap it all up checking the IE version and using the new object or the old "about:home" style:
if(window.home) {
window.home();
} else {
ieVer = parseFloat(navigator.appVersion.split("MSIE")[1]);
if(ieVer <= 7) {
window.location = "about:home";
} else {
hp.navigateHomePage();
}
}
It seems that we have to use DHTML Behaviors of Internet Explorer... I haven't found any pure JavaScript solution.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:ie>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Home Link - Test</title>
<style>
#media all {
IE\:HOMEPAGE {behavior:url(#default#homepage)}
}
</style>
<script type="text/javascript">
function goHome() { // Firefox
if (window.home) {
window.home();
}
else { // IE
if (navigator.appVersion.split("MSIE")[1] <= 7) { // IE 4-7
window.location = "about:home";
}
else { // IE 8
oHomePage.navigateHomePage();
event.returnValue = false;
}
}
}
</script>
</head>
<body>
<ie:homepage id="oHomePage" />
Home
<!-- <input type="button" value="Navigate" onclick="fnGo()"/> -->
</body>
</html>
http://msdn.microsoft.com/de-de/library/ms531398(en-us,VS.85).aspx
http://msdn.microsoft.com/de-de/library/ms531079(v=VS.85).aspx
Related
The code below which I found here
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
window.onload = function() {
var desktopFallback = "https://youtube.com/watch?v=4KnNVK-udTU",
mobileFallback = "https://youtube.com/watch?v=4KnNVK-udTU",
app = "vnd.youtube://4KnNVK-udTU";
if( /Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ) {
window.location = app;
window.setTimeout(function() {
window.location = mobileFallback;
}, 25);
} else {
window.location = desktopFallback;
}
function killPopup() {
window.removeEventListener('pagehide', killPopup);
}
window.addEventListener('pagehide', killPopup);
};
</script>
</body>
</html>
Is supposed to open youtube app based on the device. If it's a mobile device's browser through which the file was opened, the video must open up in the app. The code works fine in browser like FireFox. But it is not working on chrome. The app is not being opened, instead the browser version of youtube is being opened. That implies the mobilefallback link is being called, which is not I want.
And also if clicked from somewhere it works fine. The problem is only with Chrome. I don't know if it's some kind of chrome feature...but this is not what I need. Any help?
I can use any kind of solution. Even some other way to open up links like vnd.youtube://4KnNVK-udTU this directly in app.
Sorry if this info is not enough...I'll provide whatever it takes for you to help me out. ThankYou :)
I want print dialog to be open after PDF is rendered in browser which is working fine in firefox by adding JavaScript mentioned here but it is not working in chrome.
I have tried to add onload event and setTimeout function still it's not working.
These scripts are working in firefox but not in chrome:
<script type="text/javascript">
try {
this.window.print();
}
</script>
<script type="text/javascript">
try {
setTimeout(function() {
this.window.print();
}, 3000);
}
</script>
<script type="text/javascript">
window.onload = function() { this.window.print(); }
</script>
It's been a while since I worked with JavaScript for PDF. I believe window is a browser object and not available in all PDF readers. Try this.print() (this at the root level being the Doc object). You can check for support in your script or use try/catch to enable better cross-reader compatibility.
Here's one way to do it:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Javascript test</title>
</head>
<body>
<p>This document will trigger a print dialog.</p>
<script type="text/javascript">
try {
this.print();
}
catch(e) {
window.onload = window.print;
}
</script>
</body>
</html>
The JavaScript API implemented by the various browsers may or may not support the full API as documented by Adobe in the JavaScript for Acrobat API Reference. I have so far been unable to find a reference for other PDF viewers (such as the one bundled with Chrome).
After some testing it does seem that there is limited support by the web browsers when a PDF is rendered stand-alone (i.e. within the browser chrome) versus in a web environment (i.e. in an iframe).
Also note that Dompdf does not support embedding JavaScript into the PDF by default so you'll have to enable it in the Dompdf settings.
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->set('isJavascriptEnabled', true);
$dompdf = new Dompdf($options);
Opening a PDF (or any URL) in a new tab allows for (optionally) triggering the print dialog via the following function.
/**
* Opens a URL in a new tab. Optionally triggers the print dialog after the window has loaded.
*/
function openInNewTab(url: string, triggerPrintDialog: boolean = false): void {
if (url !== "") {
const newTabWindow = window.open(url, "_blank");
if (newTabWindow !== null) {
if (triggerPrintDialog) {
newTabWindow.onload = newTabWindow.print;
}
newTabWindow.focus();
}
else {
window.alert("openInNewTab() blocked by browser.");
}
}
}
Hello I am developing a HTML 5 game and in Chrome the animations looks great but in firefox not! I was searching over the internet and i found a solution that i need to change some settings in about:config and they are:
webgl.force-enabled=true
webgl.msaa-force=true
layers.acceleration.force-enabled=true
gfx.direct2d.force-enabled=true
stagefright.force-enabled=true
I change those setting manually and the animations looks great in Firefox. Now my question is how can I do that using javascript? Is it possible?
A discussion in the MozillaZine forum suggests creating a bookmarklet as follows (instructions and code copied from there):
Make a file in your Firefox installation folder, under the res directory, called for example 'proxy.htm', and put this in it:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Proxy Toggle</title>
<script type="text/javascript">
// <![CDATA[
function loaded() {
netscape.security.PrivilegeManager
.enablePrivilege("UniversalBrowserAccess UniversalXPConnect");
var prefs = Components.classes["#mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
if (prefs.getIntPref("network.proxy.type") == 0) {
prefs.setIntPref("network.proxy.type", 1);
}
else {
prefs.setIntPref("network.proxy.type", 0);
}
self.close();
};
self.onload = loaded;
// ]]>
</script>
</head>
<body>
Please wait...
</body>
</html>
Then make a bookmarklet to toggle the state of the proxy pref, and put this as the location:
javascript: void(window.open('resource:///res/proxy.htm'));
See: http://forums.mozillazine.org/viewtopic.php?f=7&t=87755
You should not change these settings - not on your computer and especially not on computers of other people. These settings will be enabled anyway, assuming that the hardware and drivers are capable of handling them. The force-enabled settings are for testing only, switching them on is likely to cause instability (Firefox crashes, graphics driver crashes).
Most likely reason why Firefox didn't enable hardware acceleration automatically in your case are outdated drivers - you should install current drivers for your graphics card and recommend other people to do the same.
I'm setting up a usage tracking system for a web page which will send some information back to the server when a user clicks on certain elements the page. I'm sending the information using a beacon rather than traditional ajax because I will be tracking cross domain, but I'm running into an issue in Chrome/Safari when the clicked element is a link.
Here's a simplified version of my code that demonstrates the issue.
<!DOCTYPE html>
<head>
<title>Tracking Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div id="link">
link
</div>
<div id="nolink">
<div>nolink</div>
</div>
<script type="text/javascript">
function track(event){
var beacon = new Image();
var location = "http://www.mypage.com/tracking?element=";
if (event.target.parentNode.id =='link'){
beacon.src = location + '"link"';
} else if (event.target.parentNode.id == 'nolink'){
beacon.src = location + '"nolink"';
}
}
window.addEventListener('click', track, true);
</script>
</body>
</html>
In Firefox, Chrome, and Safari clicking on "nolink" sends the message back to the server as expected. Clicking on "link" sends the message in Firefox, but in Chrome and Safari no message is sent. (Of course nothing works in IE, but I believe that's because of the event listener so I'll address it later).
Is there something else that I need to do to ensure the message is sent before the next page loads?
In case anyone is wondering, there's a django view at the other end of the beacon that looks like this:
def listener(request):
logging.info(request.GET.get("element", "received a message but couldn't find an element"))
return HttpResponse(status=200)
This works in IE, but in firefox it's very strange:
If open it normally if firefox, the designmode doesn't work but if i put a breakpoint on
this.editor.contentWindow.document.designMode
= "On";
line, and then release it (after it breaks on it), the designmode works!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript">
TheEditor = function() {
this.editor = null;
this.mainDiv=document.getElementById("mainDiv");
}
TheEditor.prototype = {
InitializeEditor: function() {
this.editor=document.createElement('iframe');
this.editor.frameBorder=1;
this.editor.width = "500px";
this.editor.height="250px";
this.mainDiv.appendChild(this.editor);
this.editor.contentWindow.document.designMode = "On";
}
}
window.onload = function(){
obj = new TheEditor;
obj. InitializeEditor();
}
</script>
</head>
<body>
<div id="mainDiv">
</div>
</body>
</html>
I don't full understand why, but opening (optionally writing content) and closing the document solves the issue (at least in FF5 on OSX):
this.editor.contentWindow.document.open();
// optionally write content here
this.editor.contentWindow.document.close();
this.editor.contentWindow.document.designMode = "on";
The other idea I had was to set a timeout around the designMode = "on" statement (I remember having to do this in the past for FF), but it did not work.
I think it has something to do with FF loading "something" in the IFRAME and it not being ready to turn designMode on.
I guess you could also use the contentEditable="true" attribute on the DIV instead.
Anyway, I hope this helps.
I think it's because the contentDocument not already created, I think you can also setup the iframe's onload event and set the design mode in this event, because this event is called when the page is loaded so the contentDocument exist !