I was doing a project and I faced an issue with the attribute download: I discovered that it isn't supported by Safari browser (according to documentation).
Here's a snippet:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<a href="http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon#2.png?v=73d79a89bded&a" download>Press to Download</a>
</body>
</html>
I searched a way to do it with pure Javascript or Angular, but I didn't find nothing. Would be great if someone had a solution.
Try
<a href="http://cdn.sstatic.net/Sites/stackoverflow/img/"
download="apple-touch-icon#2.png?v=73d79a89bded&a">
Press to Download</a>
Related
For the simple html and js code snippet, the action differ from firefox and chrome.
The simple html and js code snippet.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<head>
<title>test welcome</title>
<script>
document.write("welcome1")
alert("welcome2")
</script>
<body>
<h3>welcome3</h3>
</body>
</head>
</body>
</html>
1.Open it with firefox.
To click the ok in alert.
The executing order is : welcome1 ,welcome2,welcome3.
2.Open it with chrome.
To click the ok in alert.
The executing order is : welcome2 ,welcome1,welcome3.
Why chrome parse the simple html and js code that way?
How to make chrome behave such the same way as firefox do?
All browsers will stop execution when an alert is encountered, however, Firefox will not halt rendering for alerts. This is primarily due to the vagueness of the standard, ECMA, who writes the ECMAscript standard (upon which Javascript is built) does not mention window.alert(), as it is specific to Javascript, meaning browsers are free to implement it however they like, and they do.
You can force the popup to occur after page load with something like this <body onload="window.alert('Hello World')">, or using the defer attribute.
I am completely stumped and I'm sure this was working before.
I have a simple web page with the word "hello" in a div which does two things onload:
1) alert "2"
2) change the text of the div to "bye"
All vanilla Javascript, no libraries.
This works fine on the Chrome, IE, FF, Safari (as you'd expect). If I hit a link in the iOS Twitter app (latest version) to this web page neither of those two things happen. It seems to me that the Javascript is not being executed at all but how can this be? Has anyone else experienced this?
UPDATE
In fact vanilla Javascript will work. The alert test was misleading - I believe thats been disabled which is why it won't work. JQuery will not work however - possibly to do with the $ reference conflicting.
UPDATE 2
The problem has moved on now - my initial assumptions were not entirely correct.
The following code for a web page works:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<style>
#test {
color:red;
}
</style>
<script>
window.onload = function () {
document.getElementById('test').innerHTML = 'vanilla javascript worked';
$("#test").text("Jquery worked");
}
</script>
</head>
<body>
<div id="test">
hello
</div>
</body>
</html>
The following code does not work. The path to my script is sound and works on normal browsers, but when in the iOS Twitter in-app browser it seems the local script will not load:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
<script src="~/Scripts/jquery-2.1.1.js" type="text/javascript"></script>
<style>
#test {
color:red;
}
</style>
<script>
window.onload = function () {
document.getElementById('test').innerHTML = 'vanilla javascript worked';
$("#test").text("Jquery worked");
}
</script>
</head>
<body>
<div id="test">
hello
</div>
</body>
</html>
I have tested the issue on accessing the webpage via Facebook which also works fine either way. The problem is with the Twitter browser only on iOS.
I have tried using an absolute path to my script which also does not work.
UPDATE
This issue is not on iPad. It is iPhone only. As it was working before fine I'd say this is a bug from the latest release of the iPhone Twitter app. Will wait for a fix from Twitter.
Turned out to be that I was re-writing all requests from Twitter to a pre-rendered html instance (brombone). So when it was looking for that file it was actually looking at the brombone server not mine. I took out the rewrite and its fine now.
Completely unrelated to what I was going on about but I solved it nonetheless and may be a reminder to those with similar problems to look outside of the box and check server setups etc...
I'm working on a website in HTML5 CSS3 but I can't make my processing sketch work on other browsers than firefox.
Here is my code:
<!DOCTYPE html>
<html>
<head>
<title>Project</title>
<script type="javascript" src="processing.js"></script>
</head>
<body>
<canvas data-processing-sources="accueil.pde"></canvas>
</body>
</html>
Just answering if someone have the same error than me:
Processing sketchs work only in firefox browser if you're in localhost.
If you want to try it on other browser you need to host your website.
guys!
We are developing a realy simple web page.
But, touch events can't work in iOS8's Safari if we use iframe and web clip.
We don't know why.
Hear is our code.
And, we use web clip.
Even if we touch the div(id="hoge"), the alert doesn't appear.
Please help us...
・index.html
<!DOCTYPE html>
<html>
<body>
<div id="hoge">ABC</div>
<script>
document.getElementById("hoge").addEventListener('touchstart', function() { alert('Touch');});
</script>
</body>
</html>
・frame.html
<!DOCTYPE html>
<html>
<body>
<iframe src="./index.html"/>
</body>
</html>
I'm having an issue with a website I've created for a school assignment. As the title says, buttons don't seem to be working in Google Chrome or Firefox. I got it working in IE (the horror), where I have to Allow "Blocked Content." The problem is, I don't know what "blocked content" is referred to..
<button href="#" onclick="switchImage('slideImg')">
Play
</button>
Here I'm using Javascript, but buttons in general don't actually work, for example:
<button>
Click me!
</button>
doesn't show the visual for clicking a button.
Any help would be great!
Use following
<!DOCTYPE html>
<html>
<head>
<script>
function switchImage(str)
{
alert(str);
}
</script>
</head>
<body>
<button onclick="switchImage('slideImg')">Play</button>
</body>
</html>
It is working. You can verify it from http://fiddle.jshell.net/Jd2yP/15/
Add the mark of the web immediately after your Doctype to tell IE to run the page in the Internet security zone.
<!DOCTYPE html>
<!-- saved from url=(0014)about:internet -->