Not able to open files from HyperLink control in IE9 & above - javascript

I am trying to open a file using hyperlink control, when I click on the link no action is getting triggered, but when I paste the file:/// path in IE browser directly the file is downloaded/opened, what could be the issue below is my href content and also one can check in JSFiddle at http://jsfiddle.net/q76VB/
My Link

Have you put the file on the server that is hosting your website?
Put the file in the same folder as your html files and change the link to this:
My Link

Related

how to add custom download button in html?

Java script:
var x = 'demo'
I want a html button from which we can download x as anyname.txt in which the value should be demo
In order to download a file when clicked on a button, the file has to exist within our project files (next to your HTML file...). So you're going to have to:
Create a .TXT file yourself and write in it what you need. After that place the file in the same folder as your HTML file.
Create a button in HTML using <a> tag because in order to download it we have to reference the file using href attribute.
In order to download the file we use download attribute. That attribute will download the file with the name that it has. If you want the file to be downloaded as anyname.txt you just have to add a value that you want to the download attribute -> download="Anything you want"
The final code should look like this:
Download
Of course, style it in CSS because this looks nothing like a button.
When clicking on this button locally (before publishing you site) it will not download the file because the computer already knows you have it. That's normal. Once published, when someone (even you) click on the button it will download the file as intended.

Download pdf/word button javascript /jquery

I have data that saved in csv file. The data was used for creating some interactive graphs using d3.js and javascript. The files I have to run the graphs are some js files, css and html files. I don't need any server to run it.
Now, I want to add a download button on the page where the graphs are displayed. When user click download button, the csv will be downloaded as pdf/word file. Does anyone know how to do that? Any plugin to recommend?
Thanks a lot!
This might work for you. There is an HTML5 rule called "download" that can be added to an anchor tag.
<a href="documents/message.csv" target="_blank" download><button>Download</button></a>
In most browsers this "download" command forces the browser to open the download box. The download box itself will allow users to select their download format.
You can create an online cloud account with any free cloud-base storage (mega.nz is good), create folders for the files you want the public to see, upload those different formatted files into its own folder > copy file link and paste it in your button code like:
<a href="FILE LOCATION" target="_blank" download><button>BUTTON NAME</button></a>
on your site, it will show a rectangled grey download button that will redirect public to the folder with all those files they can choose to download.

How to download a file without the "Leave the Page" dialog or any other prompt?

In Internet Explorer 10; When i try to download a file; i get following dialog box:
Is there someway in Jquery or HTML with which this box does not get appear when user tries to download a file in application?
Update:
Also could not user target blank as flashing of new tab should not be there(customer requirements).
As asked for code, it is simple link:
<a href="www.something.com/something/something.pdf" >
jquery.fileDownload.js will help you in this.
apply file path to
function downloadPDF(thisobj) {
$.fileDownload($(thisobj).attr("href"));
}
Call this funciton on
<a href="www.something.com/something/something.pdf" onclick="downloadPDF(this)">
I'd suggest you look into HTML5's download attribute.
Excerpt from the site:
Place the download attribute on a link...
<!-- will download as "expenses.pdf" -->
Download Your Expense Report
...and when the user clicks the link, the download attribute appears
in the save dialog instead of the garbled mess that was there before.
In this case, the file will be downloaded as expenses.pdf. The
download attribute also triggers a force download, something that I
used to do on the server side with PHP.

Changing Images using extension Javascript

I have an extension installed on my Firefox browser which has a Javascript.
Also I have created a HTML file which has a Image tag with default image.
Everytime when I open that page, if my extension is enabled I want to change the Image which I have specified in my extension.
If the extension is disabled, then my default image should stay on that HTML page?
I need to perform something like
document.getElementById("check_image").src="Capture3.jpg"
in my extension JS.. so whenever I open a HTML page with Image ID "Check_Image", my extension JS should change the image to "Capture3.jpg".
Could you please tell me whether this can be done?
Thanks in advance!
Yes can be done. But you need to provide appropriate the relative path.
Folder
- mypage.html
- Capture.jpg
then you can change the image using your code in .js
document.getElementById("check_image").src="Capture3.jpg"

Is there a way to embed Github hosted javascript in a script tag?

I've had someone submit a pull request for a Javascript library I've got hosted on Github. I'd like to test it in jsfiddle, but I'd like to keep my fiddle script window clean by NOT Copy/Pasting the entire library.
Is there a way to link to the file hosted on Github, and have it served as Application/Javascript?
Basically I want to wire up a very simple fiddle, and add the file hosted on Github as a resource under the "Add Resources" tab.
First, the "raw" URL of the file on GitHub. To get this, click on the file you want, then click the "Raw" button.
Then, on jsFiddle on the left, click "Add Resources". Paste the URL in the box and, click the plus sign.
Now jsFiddle will use your JS file from GitHub.

Categories

Resources