window.url.createobjecturl() doesn't work in opera! I want to link a video file to html5 'video' tag which i selected via 'input file' html tag. I'm able to link the video in Chrome, Firefox, IE10 using window.url.createobjecturl(). So is there any snippet which i can use to solve this problem. Please help me!
Try the following snippet:
if(navigator.getUserMedia){
if(!window.URL) window.URL = {};
if(!window.URL.createObjectURL) window.URL.createObjectURL = function(obj){return obj;};
}
Related
I am trying to iframe a website for some testing purposes. I have used a chrome extension that allows you to iframe any website. Problem is that with some websites I get the error about widevinecdm. Is it possible to let an iframe use widevinecdm from the chrome browser? Or is there a bypass or someway to get passes this error?
I found a doc for this: https://sites.google.com/a/chromium.org/dev/Home/chromium-security/deprecating-permissions-in-cross-origin-iframes
Simply use the allow="encrypted-media *;" attribute on your iframe element, such as:
<iframe src="https://google.com" allow="encrypted-media *;"></iframe>
I hope this helps someone in the future.
I am using a download attribute in my link:
<a style="color:white" download="myimage" href="images/myimage.jpg">Download image</a>
It is working very well in almost all browsers. This means, if I click on the link the image is automatically downloaded. I tested it in safari 10.1.2 on my mac and it is working fine.
But on my friends mac who is working with safari 10.0.3 it is not working. He is saying that the image is only opening in a new window but not downloading.
Why is this happening and what can I do to make it work anywhere?
According to https://developer.apple.com/library/content/releasenotes/General/WhatsNewInSafari/Articles/Safari_10_1.html, it was added in Safari 10.1:
HTML5 Download Attribute
The download attribute for anchor elements
indicates that the link target is a download link that downloads a
file, instead of a navigational link. When you click a a link with the
download attribute, the target is downloaded as a file. Optionally,
the value of the download attribute provides the suggested name of the
file.
It doesn't seem to be available in iOS Safari 11.1 though from my own testing, which has me a bit confused. I'd expect them to be equal in standards support, based on their similar version numbering.
try this code:
var element = document.createElement('a');
var clearUrl = base64.replace(/^data:image\/\w+;base64,/, '');
// element.setAttribute('href', 'data:attachment/image' + base64);
element.setAttribute('href', 'data:application/octet-stream;base64,' + encodeURIComponent(clearUrl));
element.setAttribute('download', 'filename.jpg');
document.body.appendChild(element);
element.click();
document.body.removeChild(element)
This is work for me in safari version 10.0.3
Please take a look at https://www.w3schools.com/TagS/tag_a.asp
Scroll down to attributes, and you will see that the DOWNLOAD attribute is only supported by HTML5, which, as it seems, your friend's version of Safari does not support. I recommend updating the program.
Alternatively, you can right-click on the image, then click Save As..., then download it that way.
#Jarla
I've an image that I want to download on IE. After looking at Google and several stackoverflow questions I found that the best solution for the other common browsers is the HTML5 download attribute:
<a href="/barImage.jpg" target="_blank" download>Foo</a>
But this attribute is not currently supported on IE. And it just opens a new tab with the image on IE (Because it's a known file extension)
Is there any way to force the download of an image file just using html and without zipping it or any other method of this kind?
Please don't indicate javascript libraries.
I think you will not get far without JS.
Microsoft supports this tag from the Edge browser. Do you really need it for older versions?
I just read something else. You can try to fill the download attributes with a filename, so:
... download="sample.png" ...
I found this Codesnippet (force browser to download image files on click):
var link = document.createElement('a');
link.href = 'images.jpg';
link.download = 'sample.jpg';
document.body.appendChild(link);
link.click();
But I´m not sure, if this is correct...
I've built my website and it looks fine in chrome, Firefox and basically any web browser other than IE. Does anyone know any code that will direct the user straight to my error page if the user loads the site in IE?
thanks
Try this:
if(navigator.userAgent.toLowerCase().search(".net") > -1){
location.href = "error.html/" //error.html is used as a dummy page. Use your own error page url.
}
I have a mailto link on a page. It works as expected when the page is loaded by itself.
However when the page is loaded via a frameset in Chrome nothing happens. With the developer tools loaded the error "[blocked] The page at https://mysite.com ran insecure content from mailto:..." is displayed.
How can I fix/workaround this?
Yes, using "top" is the trick, but you can do it with HTML alone!
<a target="_top" href="mailto:...">email</a>
I also had this issue recently with an iframe. Using the top frame worked and should be compatible with all major browsers.
window.top.location = 'mailto:...';
Here is the solution I ended up with:
Tested with Chrome, Firefox, IE6, IE7, IE8, IE9, IE10, IE11, Safari
$("a[href^='mailto:']").on("click",function() {
window.top.location = $(this).prop("href");
return false;
});
add target="_top" or "_blank" or "_parent"
<a target="_top" href="mailto:a#b.c">email1</a>
<a target="_top" href="mailto:a#b.c">email2</a>
This will also work, and won't close the window with Facebook.
...
or
$("a[href^='mailto:']").attr('target','_blank');
Possibly because your parent frameset is https, but Chrome now seems to treat the mailto link as insecure.
I just came across a similar issue when triggering a mailto link via
window.location = 'mailto:...'
Changing it to this worked around it.
window.open( 'mailto:...')
This is my workaround until Chrome bug is fixed:
$.browser.chrome = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
if($.browser.chrome){
myWindow=window.open("mailto:"+eml+"?subject="+msb,'','width=50,height=50');
myWindow.close();
} else {
window.location.href = "mailto:"+eml+"?subject="+msb;
}
For Chrome, make instance with window.open() method and close that instance immediately. Small window will "blink" for a short period but will do the job. It is "dirty" solution but as much as Chrome's bug.
For other browsers window.location() method can be used.