How to get data from web page and preview them in my html page? - html

i need to get some data from external web page (specific text between and tags in this web page source code )
and then show this data in my html.
or get part of html code of another page
then put it in my html page by a button click for examle

This is really hard if it's somebody else's web page due to CORS. However, you should be able to if it's your web site.
Use XMLHttpRequest to get the page content.
Set the container element's .innerHTML to the textual representation of the HTML.

Related

Programatically modifying a HTML page from ASP.NET

I have an ASP.NET web app with a standard default.aspx, from within which I need to load a html page from another site (all internal intranet) and pre-populate form input controls on that loaded html page using ASP variables. Specifically, username / pwd on a login form based user details loaded by the aspx from a db. The html page also contains a considerable amount of js (shouldn't directly impact this question though).
Not sure of the best route to approach this. I have considered:
1. Loading the html page in a frame, then somehow manipulating it's DOM from another frame loaded from the aspx.
2. Loading the html during aspx page load or render, then replacing the relevant sections of the html with the new values.
I have had a stab at both approaches and ran into issues. With (2) the resulting HTML isn't recognized as HTML by the browser at all (despite the written response being just the original html relayed from the original site). I can see the HTML source in the browser, but the page itself appears blank.
Answers warmly anticipated. Thank-you.
1.if you want to go wityh iframe
You can easily modify values from communicate between parent window and iframe
from parent to iframe function
document.querySelector('iframe').contentWindow.ChildFunction(33);
from chhild to parentfunction
parent.parentfunction("4rom child")
make a function in iframe that accept an object (from parent) and populate it in.
make a function in parent that accept an object (from child) .
2.how are you "Loading the html during aspx page load or render,"
- ajax or something else?
-making a user controll
both should work fine .
( could you tell how are you loading html ?)(as it should have worked)

I have a web page. I want to show blank page when user tries to see the source code of the web page. How can I do it?

I have a web page. I want to show the blank page when the user tries to see the source code of the web page. How can I do it?
When a user views a webpage in a browser, they are viewing the sourcecode - it is just being rendered by the browser differently than a text editor would render it. So the only way to have the source code be hidden from the user is not to show it to them. So have your website serve HTTP responses with no content. In php, this would be:
<?php exit; ?>

How to display CKEditor content in HTML page?

In my application I have used CKEditor text editor to store large data.
That data may come from another html page by copying content from any web page.
When doing above scenario,
if client missed any to copy properly ended html tags from that web page, they copied incomplete html content. When client paste it inside CKEditor, it showing good.
But If I display whole content without CKEditor,
Its leading to following issues,
Page collapse , because if client copied partical (in completed content from other web page)
CSS class override
Please give solution for that.

Page url links to pages internal frame

I have a personal website, which I have made (to the best of my ability) without a template. I am not very experience in HTML so am not entirely sure if this is bad practice or not, but here is my issue.
My website consists of a frameset, which has 3 frames. Two do not change (banner and nav panel), and the other is content. The way I display my content in the main frame is through an iframe. Here's where the trouble comes. I have suggested my website to the crawler, and it crawls all the pages for content, of course. When I click on one of my links suggested by google (say, a project), the browser loads that individual .html file, without any of the rest of my frames. In other words, it does not link to the page through my index.html which sets up the formatting and page frames, but simply loads the html as a stand-alone page.
Is there a way I can avoid this, so that if a link for my website is clicked from an external link (not from my domain), the page first loads my index.html, and then the page of interest, so that it appears as if it were accessed normally from my index? I am not sure whether I should find a new way of displaying my content in the main frame so that it avoids iframes, or just need a simple script to redirect the user.
Not sure if it's useful but I've attached a photo of my page just to better explain what the frame layout is that I am working with.
Many thanks!!!
iFrames are definitely not the route to take when you are displaying consistent content... Which from what appears to be the Navigation, Header, and of course, the Content. Of course there will be an issue when a "Search Engine Spider" crawls your page... From my understanding, seeing as you are calling "content" from another page, the spider will crawl that page but will not crawl the index.html page we are currently viewing. When a "Spider" crawls a page it looks for STATIC HTML Tags/Content/Keywords/etc, and seeing as you are calling all of your content from other pages the "Spider" will treat that content as being on another page as well.
You want me recommendation? Avoid using an iFrame at all times. The point of an iFrame is to display content from another location (external), and or display static content on a page without having to scroll the current page you are viewing the iFrame on.
It is bad practice to use an iFrame, I would suggest using DIVs. Within these DIVs you may place content, images, links... Virtually anything you want, with all of the benefits of having people view your website, along with Search Engine Spiders.
I hope this helps!
Thanks,
Aaron
iFrames are a bad choice. AJAX is VERY simple these days. Just replace the big iFrame with a Div, and AJAX a page, putting the contents into that Div.
Replace your anchors with tags, and replace href with name, like so:
<div name='main.html' class='link' />
You need a div with the id 'loadHere':
Then include jQuery (it's pretty easy, google it) and at the end of your HTML put this:
$('.link').click(function(){
$.post(this.name,function(dat){
$('#loadHere').html(dat); }); });

How can I highlight some texts in Servlet (HTML) triggered by some background events?

I am using Servlet to print HTML tag make it a web page.
If i want to highlight some text inside my web page by some background events.
For example if count > 100, then highlight some text.
How can I do that? Any example or tutorial?
Many Thanks
A servlet generates HTML, and sends it to the browser. Once the response has been sent, the HTML code is in the browser, and there is no way for a background task on the server to modify anything in this HTML code.
You'll need some background JavaScript polling in the page (AJAX), that will ask for updates to the server and modify the HTML page accordingly.
Or you can regularly reload the whole page, but it's less efficient and user-friendly.