open a file when user click on a link [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a requirement to open a PPT when a user clicks on the image.
I tried by using the below code, but was not able to open the PPT when i clicked on the image or the button but its downloading the PPT file whenever i click on the image or the button. Please suggest what changes need to be done in order to open a PPT file on user click.
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>
Click to open Report:
<a href="" onclick="window.open('myFOlder/report.pptx')">
<img border="0" src="images/myPowerpoint.jpg" width="100" height="100">
</a>
</p>
<input type="button" value="Open Report" onClick="window.open('myFOlder/report.pptx');">
</body>
</html>
PS: No external libraries should be used as our project doesn't support any external libraries.

I believe that this is impossible. Since most Web browsers don't support PowerPoint documents without extensions, they will automatically download them. You could, however, upload the presentation to a website that could display PowerPoint documents (e.g. Google Drive), and include a link to the uploaded file.

Related

I want to embed youtube video and also show gallery/playlist [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to show in a gallery all of the videos from our youtube channel. I am using <iframe> but it is only showing one video. How can I show all of the viedos from our channel?
<div>
<iframe src="https://www.youtube.com/embed/Wyq6YeoM2ZA?ecver=2" width="640" height="360" frameborder="5" style="position:absolute;width:70%;height:60%;left:15%" allowfullscreen playlist></iframe>
</div>
You can watch in Youtube API. It is documented well in several progamming languagues. Here is a snippet in javascript:
// Sample js code for playlists.list
// See full sample for buildApiRequest() code, which is not
// specific to a particular youtube or youtube method.
buildApiRequest('GET',
'/youtube/v3/playlists',
{'channelId': 'UC_x5XG1OV2P6uZZ5FSM9Ttw',
'maxResults': '25',
'part': 'snippet,contentDetails'});
More on https://developers.google.com/youtube/v3/docs/playlists/list.
This HTML will embed a player that will show all of your videos. Replace YOURCHANNELNAME with your channel name.
<iframe src="http://www.youtube.com/embed/?listType=user_uploads&list=YOURCHANNELNAME" width="480" height="400"></iframe>

I am new to programming and I cannot figure out why my external js file wont work [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I cant get my external file to work. I just want a simple alert, it works in my main html file but not when I link the external js file.
<!doctype html>
<html>
<head>
<title>Javascript Tutorial</title>
</head>
<body>
<div class="container">
<h1>Let's Learn Javascript!</h1>
<p class="lead">...cause Javascript Rocks.</p>
</div>
<script src="scripts/main.js"></script>
</body>
</html>
It is proper practice to define script tags in the <head> or <footer> tag. Also when linking to your Javascript file the methods in the file won't be called automatically unless you use document.ready.
If you wish for a function to be called as soon as the page loads use document.ready or create a script tag in the <head> or <footer> and call the function from there:
<script type="text/javascript">
myfunction();
</script>
Also in the JS file code shouldn't just be laying about, they should be organized/enclosed in functions.

Load .html into div by using a search bar [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm primarily wondering if this is even possible without PHP, and perhaps some guidance if it is. I have the feeling I'm overthinking the process.
Currently I'm loading specific .html's into a div with ease by button clicks. However, I have been trying to load an .html into a div by using a search bar (as the title explicitly states).
For instance, I search for "Apple" and expect "Apple.html" to load into the div. I understand that javascript cannot/shouldn't search local files without the aid of PHP, but can it not 'assume' that the file is there and load it? According to my logic it wouldn't be much different than a button click.
you can use jquery
your all files should be at same place where actual page exist otherwise you have to specify path also.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>html</title>
<script src="http://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
<input type="search" id="search">
<input type="button" id="button" name="">
<div>
</div>
<script type="text/javascript">
$("#button").on('click', function(e){
$('div').load($("#search").val() + ".html");
});
</script>
</body>
</html>

JavaScript: Can the entire page be loaded dynamically? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
When I try to go to Gmail and FaceBook with my JavaScript disabled, I am greeted with the following:
The content in the images is displayed in <noscript> tags, but the rest of the usual page content isn't there. The Gmail source has a few empty <iframe> elements, but the FB page is empty, save for the <noscript> element, and a couple <script> tags.
I would like to have similar behaviour for my site, but am unsure how to only load the page content if the user has JS enabled. I can put in the <noscript> element, and have a div centred on screen with a "You need JS enabled" message, but the rest of the content would still have loaded behind it.
There are a couple solutions here and here, but they only have the main content as:
display: none;
and the set it to block; via JS. But that would still show up in the source.
Can I entirely prevent loading page content when JS is disabled, and only display the "Oops, you need JS enabled" message?
Do not put the content in the first page, and just put a <script src="…"> which loads the actual contents via AJAX. Your source should then roughly follow that template:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="libraries.js"></script>
<script src="load-page-contents.js"></script>
</head>
<body>
<noscript>
This website is an interactive editor for 3D graphics or something
really complex that can't be done at all in plain HTML, and therefore
needs JavaScript.
Click here to read more about this project.
<img src="screenshot.jpg" alt="Obligatory screenshot, to compell the
user to turn on JavaScript because this looks So Cool ™." />
</body>
</html>
Think twice about it, however. Does your site really need JavaScript to work? Can't at least a dumbed-down version be displayed otherwise? There are lots of reasons to have JavaScript disabled (screen readers, search engines, security issues, easy way to disable lots of blinking flashing annoying ads)
Simply load the whole page with an AJAX request and hide the error message using Javascript. Then the error message will remain if they have Javascript disabled, and the page will be loaded if it is enabled.

How to display a pdf in a modal window? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a modal window, which contains an anchor text. When i click on this link, it must call a pdf housed somewhere else and display it in a pop up . How can I do that ?
Kindly help .
You can do this using with jQuery UI dialog, you can download JQuery ui from here Download JQueryUI
Include these scripts first inside <head> tag
<link href="css/smoothness/jquery-ui-1.9.0.custom.css" rel="stylesheet">
<script language="javascript" type="text/javascript" src="jquery-1.8.2.js"></script>
<script src="js/jquery-ui-1.9.0.custom.js"></script>
JQuery code
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$('#trigger').click(function(){
$("#dialog").dialog();
});
});
</script>
HTML code within <body> tag. Use an iframe to load the pdf file inside
this link
<div id="dialog" style="display:none">
<div>
<iframe src="yourpdffile.pdf"></iframe>
</div>
</div>
You can have a look at this library: https://github.com/mozilla/pdf.js it renders PDF document in a Web/HTML page
Also you can use Flash to embed the document into any HTML page like that:
<object data="your_file.pdf#view=Fit" type="application/pdf" width="100%" height="850">
<p>
It appears your Web browser is not configured to display PDF files. No worries, just click here to download the PDF file.
</p>
</object>
You can have an iframe inside the modal markup and give the src attribute of it as the link to your pdf. On click of the link you can show this modal markup.
you can use iframe within your modal form so when u open the iframe window it open inside your your modal form . i hope you are rendering to some pdf opener with some url , if u have the pdf contents simply add the contents in a div in the modal form .

Categories

Resources