cross-browser

JavaScript date-only format guaranteed to be interpreted as local time in modern browsers

北城以北 提交于 2019-12-24 13:48:06
问题 I am looking for a date format (only year, month and day, no time component), that will be guaranteed to be interpreted as local time, in all reasonably modern browsers, when passed to the Date() constructor in JavaScript. The (3-letter English month abbreviation) (2-digit date) (4-digit year) format seems to work. When I do new Date('Apr 01 2015') on my English system, in Chrome, with my machine being in the Eastern timezone, I get back Wed Apr 01 2015 00:00:00 GMT-0400 (Eastern Daylight

TypeError: undefined is not an object (evaluating 'newWindow.focus')

烂漫一生 提交于 2019-12-24 13:28:27
问题 I am having the following javascript which open ups a child window with the sizes and align it int he center of the screen function PopupCenter(url, title, w, h) { // Fixes dual-screen position Most browsers Firefox var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left; var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top; var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document

How to fix this jquery function to work in IE?

二次信任 提交于 2019-12-24 11:05:01
问题 I am relatively new with Javascript but managed to somehow get this code to work on chrome, firefox, safari but it doesn't properly on IE. First look at this code and then after that I will explain what seems to be not working: <!doctype html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="http://www.domain.com/test/wtf.css" /> <script type="text/javascript" src="/js/jquery-1.7.2.min.js"></script> <script type="text/javascript"> $(function () { var

Inconsistent results between different browsers with my Javascript code for randomizing a list

两盒软妹~` 提交于 2019-12-24 11:04:26
问题 I got this piece of code from a website for randomizing a list of items. [This is for a music player that randomizes the songs (list) in every new visit by the user, thus not boring them by starting with the same song that they heard in the past visit] $(document).ready(function(){ $('ul').each(function(){ // get current ul var $ul = $(this); // get array of list items in current ul var $liArr = $ul.children('li'); // sort array of list items in current ul randomly $liArr.sort(function(a,b){

Alternatives of spread syntax

依然范特西╮ 提交于 2019-12-24 11:04:06
问题 I see several uses of spread syntax in a code. For example: function tree2table(tree) { var children = tree["children"]; if (children === undefined) return []; var result = []; for (var i = 0; i < children.length; i++) { var child = children[i]; var link = [child["name"], tree["name"], child["size"]]; result.push(link); result.push(...tree2table(child)) } return result } However, spread syntax is not supported in IE. Does anyone know what is the best way to change result.push(...tree2table

Are scroll bars always the same width in different browsers?

╄→гoц情女王★ 提交于 2019-12-24 10:46:39
问题 I need to make a CSS adjustment to compensate for a scroll bar. So I was wondering- are scroll bars always the same width in different browsers and operating systems? I have two tables, one above the other, with matching columns widths (set to percentages). One table needs a scroll bar, so I want to add another column in the table above it to compensate for it, so the columns line up. 回答1: Scrollbars aren't even counted the same in different browsers, some of them put them inside the frame,

What are my options to avoid this error (and document.write) in Internet Explorer?

99封情书 提交于 2019-12-24 10:04:30
问题 I'm maintaining some code that has far too many document.write instances. For example, the code would document.write a div, then use the DOM to find that div, then append an <img> to it. I've tried to refactor a relevant piece to look more like this: var node_to_append = document.createElement("div"); //node_name is a hardcoded constant node_to_append.id = node_name; var i = 0; for( i = 0; i < request_urls.length; i++) { var image_to_append = document.createElement( "img" ); image_to_append

Why is Firefox not honoring flexed div's height, but Chrome is?

你离开我真会死。 提交于 2019-12-24 10:01:25
问题 This is best illustrated with a simple example. I have a container with display: flex and flex-direction: column , with a single div inside with height: 300px and flex: 1 . Chrome renders the nested div at 300px tall, but Firefox renders it as a single line. Is this just a nuance between the implementation of flexbox between the two browsers, or is this bad code somehow? If a nuance, what's the best way to mitigate? .container { display: flex; flex-direction: column; } .container > div {

HTML file input — “accept” attribute not working

亡梦爱人 提交于 2019-12-24 09:59:20
问题 After reading through the comments on this post, I came up with the following syntax for the accept attribute: Images <input type="file" accept="image/jpeg, image/png, image/gif, .jpeg, .png, .gif"> Audio <input type="file" accept="audio/mpeg, audio/x-wav, .mp3, .wav"> This works perfectly on desktop browsers, but does not appear to filter files at all on iOS or Android. Are there any cross-browser solutions available? 回答1: <!DOCTYPE html> <html> <body> Image:<input type="file" name=

Disabling JS from within Website for specific browsers

旧时模样 提交于 2019-12-24 09:58:58
问题 My Website is completely designed to without javascript. JS is added completely non intrusively. Now I don't want to test the JS on all browsers (notably older IE versions), because they give no feedback for debugging, and it's just not worth my time. So I'd simply like to disable JS on some browsers (or the opposite: allow it on the browsers I have tested it with). Is there a way to do that? Or do I have to create a JS flag that I have to consult every time before I execute JS? (really don't