Can i pull html content from a exterior file? [duplicate] - javascript

This question already has answers here:
jQuery.load to load HTML file
(2 answers)
Closed 5 years ago.
This might be a really stupid question... But i'm making a menu. Would it be possible to write the code for that menu in an outside source? and then pull it using Jquery or javascript and have it replaced in a location or something?
The menu would look like:
<span class="menulist">
<span id="homemenu">
<button id="home">Home</button<
</span>
<span id="onemenu">
<button id="one">Page One</button<
</span>
</span>
And have all that saved in a seperate file. I dn't care what type of file, .js, .txt, .html. and just pull the text and dump it as objects in a location specified for menu?
If this theoretically works here, I could use it elsewhere. such as writing the story narrative in one file and revealing it, or revealing it in part, and having the layout and technical workings on another file.

Take a look at jquery's load function.

Related

Download a page only with the link? [duplicate]

This question already has answers here:
How to download a file with Node.js (without using third-party libraries)?
(31 answers)
Closed last month.
I want to know is there any way to download a page only with the link.
For example : link and at the end we got the source code.
Here is my pseudo code :
/* 1- create a variable and save the link of the current page in it 2- download the saved link source code in a HTML file */
Use the HTML download attribute e.g. <a href="/images/myw3schoolsimage.jpg" download>

How to hide my javascript but let other download my webpage with thr script without them knowing? [duplicate]

This question already has answers here:
Can we hide javascript loading from the user?
(2 answers)
Closed 4 years ago.
So this is how it goes... I wanted to create a javascript that redirects links to my URL. So if anyone copies my webpage, they try changing my links, when they upload it to their server, her links will still redirect to my links. Is this possible with js? Or if I use PHP to hide the location of my js. I want that js to still work in the webpage they copied and use. Like a sticky clickjacker. That's hard to find and remove. Or if possible they cant at all.
I wanted to create a javascript that redirects links to my url.
This means that the user would have to already be at your URL because the JavaScript to redirect to your URL can only be added to pages that you control.
So if anyone copies my webpage, they try changing my links, when they
upload it to their server, her links will still redirect to my links.
As soon as they make a copy of your code, it's their code and they can upload it anywhere they want without your knowledge. And, if they can change your links, they can also just remove any JavaScript you may have had in the file.
What you want to do is not possible.

Inserting part of webpage into another using html only [duplicate]

This question already has answers here:
Can an iframe only show a certain part of the page?
(8 answers)
Closed 8 years ago.
I am trying to build a webpage using wix.com, and I want to include part of another website into mine. I can add html code. I am trying to get the featured poet on poetryoutloud.org into mine. This changed everyday and I only want this part of the webpage. I know that if I wanted to include the whole webpage I could use an iframe element, but this is only part of it
You can use an iframe
or alternatively you can use ajax, here an example using jQuery.
$("#yoursite-html").load("yoursite-html.php");
Please note if content is on another domain as described in your answer (CORS issue), you have to use a simple proxy example below:
PHP in file "yoursite-html.php":
echo file_get_contents("http://www.yoursite.com/");

CSS Overide in Header [duplicate]

This question already has answers here:
Removing or replacing a stylesheet (a <link>) with JavaScript/jQuery
(9 answers)
Closed 7 years ago.
So quick question, I just bought a template of a website that I really like, only for the about us page. I use a Volusion website, so we have a main CSS for the main template, and I want to be able to just have one page, the about us page, use this new css. If I put it in the body for the about-us page, it is obviously over ridden by the sites main css.
If it put it in the header with the rest of the css, it then throws off CSS all over the website, when I only wanted it reference to the about-us page.
Without having to go back, and rewrite every piece of CSS to make it unique only to the about-us page, so there is nothing conflicting, is there any quick method of having a unique set of CSS for just one page with a special jQuery call, or href. I don't want to use a ton of !important either.
Wrap the About us in a id wrapper like this
<div id="about-us-wrapper" >
{...}
</div>
Then in the imported the CSS file, append
#about-us-wrapper .xxx
in front of each line.

Javascript download contents of a element [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Download textarea contents as a file using only Javascript (no server-side)
Basically I have a live html editor in javascript and I want to add the ability for the user to click a button or link and download their html document. My idea was just to download the file with the contents of the textarea element, but I can't seem to find out how.
I do have php if any server-side things are needed, it doesn't have to be strictly javascript but I want an option to do this. Thanks! And please comment because sometimes my questions can be rather confusing :|
Well there is an another simple way to do this on the client side itself, i believe that will be a best fit for you because, the html editing is done on the client side and you dont need any server data.
http://pixelgraphics.us/downloadify/test.html
the above component lets us download a content from the client side and WYSIWYG editor is a DIV with a Contenteditable true attribute which allows editing, so you can get the html content and pass it on to this component for client side download

Categories