cross-browser

Javascript storing/state of global data/object

爷,独闯天下 提交于 2020-01-01 16:53:29
问题 Is there a way to store global data in the window object such that the data can survive page reloads/refresh. So lets say I assign my global data/object - window.myObject = myProductObject And the user refreshes/reloads the page or may be jumps to another page of my website. Is window.myObject still available after the page reload? NOTE -: I cannot store the object in a cookie, since its a object, I mean it could be a reference to another custom object or it could refer to another "window"

How do I simplify this header with lines on the side, so that it doesn't need css3 background properties?

二次信任 提交于 2020-01-01 15:07:01
问题 I have a css class for centering a heading, and adding vertically centered lines on either side. Problem is, it uses css3 background properties, and not every browser supports those. So I'd like to simplify this for cross browser compatibility, but am not sure how to do that. Is there a simpler way to achieve this, without the css3 background (and without adding any extra elements or static heights/widths )? demo here .section-heading { display: table; white-space: nowrap; } .section-heading

JS to detect browser width and height works in Chrome & Safari but not IE9 or FF9

核能气质少年 提交于 2020-01-01 14:39:24
问题 Is there any reason why this code would work in Safari and Chrome but not IE or FF? JS function load(){ w.value = window.outerWidth; h.value = window.outerHeight; } HTML <input name="h" id="h" type="hidden" value="" /> <input name="w" id="w" type="hidden" value="" /> Click here for the entire page's source code Thanks in advance for the assistance. Edit: I figured out what was wrong. The following had to be added to the load function var width = document.getElementById("w"); var height =

IE9: Script only works in debugger, but not when NOT debugging

你。 提交于 2020-01-01 10:57:09
问题 I have some trouble with Internet Explorer's compatibility. I'm building an online tool with massive usage of HTML5 canvas, CSS3 and JavaScript. The program works fine in all major browsers, except for Internet Explorer. IE9 switched into compatibility mode, so I set <meta http-equiv="x-ua-compatible" content="IE=9"/> to force IE to process the page with IE9 standards. IE does no longer fall into compatibility mode, but the script does still not work properly. Some basic functionality as

Is it possible to add a browser code in javascript

删除回忆录丶 提交于 2020-01-01 08:29:06
问题 I would like to create a webpage with browser specific in javascript. For example: can I use code like this in my coding part chrome.tab.onRemoved.addListener() in my webpage. If it is possible please suggest me. 回答1: What exactly are you tring to acheive? If you want to know when the tab in which your webpage is loaded is closed, then window.onunload should help you. If you want to know when another webpage is closed, you cannot do this. UPDATE: You said that you want to know when the user

Differences in JSON.stringify result between browsers

不羁岁月 提交于 2020-01-01 08:20:48
问题 When I JSON.stringify() the following code: var exampleObject = { "name" : "Žiga Kovač", "kraj" : "Žužemberk"}; I get different results between browsers. IE8 and Google Chrome return: {"name":"\u017diga Kova\u010d","kraj":"\u017du\u017eemberk"} While Firefox and Opera return: {"name":"Žiga Kovač","kraj":"Žužemberk"} I am using the browser's native JSON implementation in all 4 browsers. If I undefine the native JSON implementation and replace it with the one from json.org, then all browsers

Why doesn't Twitter and Google API documentation encode ampersands in URLs?

[亡魂溺海] 提交于 2020-01-01 07:56:27
问题 I have read I should encode my ampersands as & in HTML. However numerous code samples from respected companies somehow forget to do this . Just a few examples off the top of my head: Google Web Fonts sample code: <link href='http://fonts.googleapis.com/css?family=PT+Sans&subset=latin,cyrillic' rel='stylesheet' type='text/css'> Google Maps documentation: <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&language=ja"> Twitter Anywhere official tutorial:

Can I code CSS specifically for Mac browsers?

不问归期 提交于 2020-01-01 06:17:32
问题 Site: http://clientfiles.priworks.com/lgmanagedportfolios/test/investment.html I have been working at this web page for a while now trying to get the left side of the first submenu link to line up with the left of the 1st parent/main menu link. I don't think there is a logical way of doing it but after much fudging I am close to getting it just right. The position is consistent for all win browsers and all Mac browsers (with some conditional CSS) but not for Win and Mac browsers together, for

Can I code CSS specifically for Mac browsers?

孤街浪徒 提交于 2020-01-01 06:17:28
问题 Site: http://clientfiles.priworks.com/lgmanagedportfolios/test/investment.html I have been working at this web page for a while now trying to get the left side of the first submenu link to line up with the left of the 1st parent/main menu link. I don't think there is a logical way of doing it but after much fudging I am close to getting it just right. The position is consistent for all win browsers and all Mac browsers (with some conditional CSS) but not for Win and Mac browsers together, for

Alpha becomes black when coming from clipboard on Mozilla Firefox and MS Edge

烂漫一生 提交于 2020-01-01 05:55:38
问题 I'm using a code from here to paste images from clipboard on a page. It works fine in all browsers (Chrome, Firefox, Edge and Opera). The problem is: when the image is a PNG or GIF with alpha channel (transparent areas), the alpha becomes black in Firefox and Edge. Here's the code snippet (or jsfiddle if you prefer): document.getElementById('pasteArea').onpaste = function (event) { // use event.originalEvent.clipboard for newer chrome versions var items = (event.clipboardData || event