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

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/");

Related

Is it ok to add meta tag in head using jQuery? [duplicate]

This question already has answers here:
How to add meta tag in JavaScript
(5 answers)
Closed 3 years ago.
I want to add meta tag conditionally in an HTML page, i am not sure if it is ok to do so or not using jQeruy ready even. The example is given bellow.
var myHost = window.location.host;
if(myHost.startsWith("techstag")) {
$("head").append('<meta name="robots" content="noindex,nofollow">');
}
In short, it may or may not work.
It would work in the sense you'll see the meta tag in page when you inspect it.
But, if you are intending to do this for SEO purposes
For the most part, it won't work, as most web crawlers do not execute javascript while scanning the web pages.
It will work for crawlers that do execute JS (e.g. Google's)

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.

Javascript and Html - Return url adress in html code [duplicate]

This question already has answers here:
How to display JavaScript variables in a HTML page without document.write
(9 answers)
Closed 7 years ago.
I'm trying to get the full url adress of the curent page using html and javascript. But I'm don't really good at web languages so I call for you're help.
Here is what I'm trying:
Your website url is: <script>(window.location.host)</script>
http://jsfiddle.net/5U366/92/
The way you could do it (not recommended is)
Your website url is: <script>document.write(window.location.host)</script>
better way would be to put a placeholder there and replace the content with innerHTML/textContent.
Your website url is: <span id="loc"></span>
<script>document.getElementById("loc").textContent = window.location.host;</script>

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

No javascript detect in JSP page [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to detect if JavaScript is disabled?
My question is how to detect in the server side web application that there is no javascript enabled?
I know the tag but I want to do it in servlet or with pure java. I do not want to use noscript tag
because I have to redirect the page if there is not javascript enalbed.
Thanks in advance.
OK I found a way to do it.
Make two div tags.
The first one will contain the noscript text
and the second one will contain the main content of the page.
With javascript you just have to hide the one div and to show the other. If there is no javascript the div with the text won't dissapear and the other won't show.

Categories