How to get innerText from IFrame (on server-side / on client-side)

Hi, is there some posibility how to read inner text from IFRAME on server-side ?
I've tested it with innerText and InnerHtml but it doesnt work

I also tested it on client-side with JavaScript but I'm still not able to read innerText or innerHTML of that frame.

<%

@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="AJAX_Test.WebForm1" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml" >

<

head runat="server">

<title>Untitled Page</title>

</

head>

<

body>

<

script language="javascript" type="text/javascript">

function

OnUpdate()

{

var

hidden = document.getElementById("Hidden1");

var

frame = document.getElementById("frame1");

var

x1 = frame.innerText;

var

x1 = frame.outerText;

}

</

script>

<form id="form1" runat="server">

<div>

 

<iframe id="frame1" src="http://dotnet1.cic-software.de/carspecs" onactivate="OnUpdate()" runat="server" style="width: 1022px; height: 715px"></iframe>

<input id="Hidden1" type="hidden" runat="server"/>

<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

</div>

</form>

</

body>

</

html>

 

0
Michal_S
12/1/2006 10:19:20 AM
asp.net.web-forms 93655 articles. 5 followers. Follow

8 Replies
2106 Views

Similar Articles

[PageSpeed] 57

Michal_S:
Hi, is there some posibility how to read inner text from IFRAME on server-side ?

Not using InnerText or InnerHtml, but you can use some sort of screen scraping technique. Check out System.Net.WebRequest Class (example on how to do it in this link).

Hope that helps!

 

--
Tarjei

 

0
tarjei
12/1/2006 2:36:23 PM

hi,

am afraid the innerText and innerHTML is the text between <iframe>and</iframe>

 <iframe id ="frame1" runat ="server" src ="Web.Config">123</iframe> the innerText and the innerHTML is 123

if you want to get the content of the iframe, using javascript

You can get the content of a iframe using two different methods.

First, you can use the windows's frames list to get a reference to a specific frame. For example:

window.frames[0].document

This line will get the first frame in the window and return its document. You can also replace the index with a name corresponding to the name attribute on an iframe.

In chrome installed applications, you can also use the contentDocument property of the iframe. The following demonstrates both methods. Both variables 'method1' and 'method2' will have the same value.

 

<script>
function getContent()
{
  var method1 = window.frames['hello'].document;

  var iframe=document.getElementById("hello");
  var method2 = iframe.contentDocument;
}
</script>

<iframe id="hello" name="hello" src="hello.xul"/>
0
jessjing
12/4/2006 3:05:06 AM

Hello,

I guess I have a related question, so I will ask it here.

I can access the content of the iframe using above trick.

However, how can I change the content?

I tried self.window[2].document.body.innerText = "abc";

but does not seem to work.

Any ideas?

 Thx,

 


Paresh
0
Paresh
12/27/2006 5:23:16 PM

hi,

I think u can assigned it from server side

 <iframe id="if1" runat="server" src="Web.Config">123</iframe>

if1.InnerText="abc";

0
jessjing
12/28/2006 3:43:16 AM
jessjing:
I think u can assigned it from server side

 <iframe id="if1" runat="server" src="Web.Config">123</iframe>

if1.InnerText="abc";

Now I'm curious; what good would that do exactly? Your code would change the text between the opening and closing iframe tag from "123" to "abc". That has nothing to do with the actual content of the iframe. The content between the opening and closing iframe tag is what gets displayed in a browser not supporting frames.

--
Tarjei

0
tarjei
12/28/2006 12:13:15 PM

Tarjei,

 Actually I need to do it on the client side using JavaScript.

I am not worried about other browsers at this stage since it's an intranet application and we use IE internally.

Thanks,

Paresh.


Paresh
0
Paresh
12/28/2006 12:31:54 PM

hi,

first sorry for misunderstandingEmbarrassed

try this, it should work

<iframe id="if1" src="" mce_src=""></iframe>

 <a href="http://forums.asp.net/EditPost.aspx?PostID=1511898&ReturnUrl=%2fShowThread.aspx%3fPostID%3d1511898%231511898#" onclick="document.getElementById('if1').src='http://www.bwd-scouts.org.uk';return false;">ABOUT me</a>

 

0
jessjing
12/29/2006 3:36:52 AM

There is a simple solution to this problem ,you have just get ID of the IFrame and Set the Contents of the Body

 

function setContent() { if (iView.document.body) { iView.document.body.innerHTML =""; iView.focus(); } }

 function GetContent() { document.Form1.hdContent.value=iView.document.body.innerHTML; document.Form1.submit(); }

Where IView is the ID of th IFRAME , and these are the JS functions .

 

Enjoy!!!!

0
Himanshu_nhn
12/6/2007 1:37:35 PM
Reply:

Similar Artilces:

How to Access/Pass Server Side Array Variable at Another Web Form's Client Side
Hi All,I struck up with some intrested senario at my application development...hope some body will guide me or sends me some code snippets....Thanks in advance.Senario is like this.....in A.aspx (using C# .net 2.0 as code behind) I am going to have a array variable basically it is an TWO Dimensional array after populating the values in array I need to redirect/ reload another web form B.aspx, here i need to access the array in B.aspx client side JavaScript.How can I do this...Thanks AgainRaju Dont do a redirect but use server.transfer. That way the previous page will still hold its value, ...

Getting my client-side variable over to server-side
Ok so I have looked at a few posts on this subject and I can't quite figure out how to apply the idea to what I am doing here. I am using javascript to take amounts from 7 different textboxes and add them up on the fly, dropping the total in the 8th textbox. After they fill in that information they click button (postback) to continue throughout the form... what I need is for the "textboxTotalAmt" to move from client-side to server-side.  So I can access that total amount later in the form. Here is the Javascript piece... <script type="text/java...

differences between server side asynchronous Web methods and client side asynchronous Web methods
Hi,   can anyone expalin what are the differences between server side asynchronous Web methods  and client side asynchronous Web methods in ASP.Net 2.0 ?   any best articles on serverside asynchronous Web methods  ?   Thanks,  hi, check this url, Server-Side Asynchronous Methods for ASP.NET, http://www.codeproject.com/KB/cpp/asyncws.aspx   Calling the Server-Side method asynchronously from Client Script, http://www.c-sharpcorner.com/UploadFile/dipenlama22/Callbacks07182006093320AM/Callbacks.aspx...

Firing both Client side event and server side event for server side button
I am having some difficulties getting this to work.. I have button_click (Asp.net) and ClientClick (Javascript).  Javascript is firing fine.  Server script is not. may be you have return return false in the in the javascript which is why its not firing server side event.You should add javascript evelt like thisbutton1.onclientclick = "functionname" Function should nopt return false. Vikram www.vikramlakhotia.comPlease mark the answer if it helped you...

get server side datetime but run at client side
How do I get the server side datetime eg( 4 Aug 2006  6:12 : 01(seconds) AM  ) which the time is something similiar to ticking clock, once it get the server side datetime, it will pass to the javascript. From javascript it will increment the second by one, it is just similiar to ticking clock, after 10 seconds it will synchronize to the server datetime which means it get the latest server side datetime.   Is there any guide ? thanks in advance!!!kiwi_cyh Hi, It seems you want to synchronize the time in client side display with the server. You can use asynchronous clie...

How to get the Client side values in server side code.
Hi all, i have a proble i need to get the client side javascript values in C# code at server side. how can i pass those values? i am using version 1.1, i kno thatwe can use callback events mechnisam in 2.0 or ajax ,apart from that how we can pass? My problem is i need to stop the execution of the code based on after reciving values from the client   any ideas please???   Million thanks RamCheersRam MCP Hello Ram, a common approach is from javascript set an hidden field, then issue a postback. On the server-side, handle the post-back. Feel free to go deeper in your que...

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

form double validation- server side and client side
Hi! I would like to make a server side validation after calling a js function that makes the client-side validation. I do not understand couple of things: 1. Do i need a server side button or  a simple HTML submit button in order to call both of the tests? 2. How do i call a server side function which is written in csharp  after i finish my JS validation (the submit  button is calling the JS function for validation first.)- is it possible to call it directly from a js function? 3. I know that my toolbox on asp.net  contains validation controls who probably are b...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

Getting hidden variable value from server side in client side
hi,        I am struck in problem. I have a hidden field in my form and i am setting some value in that.         Now i wnt to use this value from client side but i m not able to retrieve it. All i am getting there is an object.         I feel the hidden field is not able to hold that value.         <input type="hidden" id="hdnVar" runat="server" />         in code behind      ...

web forms with client and server side controls??
Hi, I have a form that has client and server side controls. I have a problem in that any client controls (textbox) within the form runat="server" can not be accessed with client side code. Anyone got any ideas why and what work arounds are possible. Regards, Graham. once a form element is inside a <FORM> tag, you can no longer refer to it by its ID alone. you have to refer to it by formname.elementid or document.all.elementid. use document.getElementById(yourtextboxid) to get a ref to the element in the form. using this allows u to bypass the formname. but you must have dom compliant browser like IE. i use a wrapper function to get objects in my clientside scripting... something like... //////////////////////////////////////////////// // find an element and return object for it function getRef(id) { try { return document.getElementById(id); } catch (error) { var sAlert = 'ERROR: fnc {getRef} return the following error: \n '; sAlert += '[ ' + error.number + '] - ' + error.description; alert(sAlert); } } a little bit over the top but saves a lot of typing... J...

Web solution help
------=_NextPart_000_015B_01C35A1D.F3D06C60 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I was looking for an idea of how I might accomplish something and if = Perl/CGI is going to handle what I have in mind. I have a site that will list = information with links to another site or there may just be additional information available. To = include the=20 more information with every listing would create a very large web page. = I'd rather have something like the following: Here is item one (more information on i...

client-side and server-side?
hi, can someone tells me how diff is client side and server side are these two? When I tried to do validation ... I would use Javascript ... which has something like: document.forms[0] ... I think that's client side. My understanding on server side is the "form" ... like u will have <form action=".." method=post> ..... </form> ... so it will send to server ... am I on the right track? Are there any other type of server side examples? Hi, ASP.NET itself is server side. Every piece of code processed is done on a server. What comes out of this is sent ...

Client-side call from server-side form... anyone, anyone, Bueller?
I'm hoping someone can help me here, I am about at my wits end.   I am a part of a team building a rather rich web app that requires multiple possibilities as to the form layout.   Right now, we are using javascript to dynamically build the form according to the needs of the "search" that is being created.   i.e., one person with one house, two people with one house, three people two houses, all dynamically created by the user as they are creating the search.   Obviously depending on how the search form has been created there would be any...

Client Side HTML Radio Buttons not Posting with Server Side Form
I have a server side form that is posting when an HTML client side button is clicked.  However, the value of my html client side radio button is null when I call Request.Form("htmlradiobuttonlist") on the resulting page.  Does anyone know why the form won't the post the value?  Please help!  Thanks in advance.I'm still using dot net 1.1.  I can use server side buttons or server side radio buttons.  I can explain why if necessary.Below, you can see the HTML radio buttons in the datalist.  The JS function works, but is omitted from below.<form id="form1" a...

Server Side or Client Side
Hi I'm a bit confused about this whole server side / client side thing. Are applets, embeded objects consider client side? If I have a form within my aspx page which connects to a database on the server side what is it considered? If I have some business logic written within a VB file when the client access the functions within that business logic (for example some kind of validation function) does the client browser actually downloads that VB file? Can someone suggest how to differentiate between client side and server side components within a asp.net based website?  Hi, i can&#...

communication between client side(java script) and server side in .net project
I have a question which is, when building a .net project, we are able to use server side code and client side code(java script). How do they communicate? Thanks Client Side coding works with the WebBrowser. So when ever you write client side code you have to keep browser compatability in your mind and you have to code. Server Side code works with Web Server (IIS) and it's ASPNET ISAPI's. The won't directly communicate with each other. But using AJAX you can all server side code from Client Side! Example article on Ajax@ http://www.devarticles.com/index2.php?option=content&task=...

Client side and server side
We have a application, where we have some validation on the clientside using EnableClientSideValidation. If you don't have fullscreen you can't see some of the error-messages. What we want is to jump to the place on the page where the message is displayed. One problem is that the button is a serverbutton (runat="server"). How can we accomplish this on the clientside using the same button. I have tried to use "onClientClick" and a link something like this:   <A HREF=http://forums.asp.net/AddPost.aspx?ForumID=18#form>form<...

Server-side or Client-side
In general, I'm wondering if there are any criteria to use when choosing between using a client side element or a server side element. For example, if I'm going to put an HTML table on a page, how do I decide whether or not to use a server control?  Should the server side always be chosen or if there is not explicit server side functionality required is it better to opt for a "normal" client side table? Obviously, if there is a need for server side control the question is answered, I'm looking more at more ambiguous situations. Thanks  This is from Micros...

What is Client Side and Server Side?
I am New of ASP.Net What we can and should do client side and Server Side? What uses? Please any one clear my doubt. Thanking YouEndendrum Priyamudan P m R Clientside is basically what a person can see and serverside is where actions get processed. that's kinda simply puyt but thats the deal, you code serverside, and the html and javascript it generates let's the users for example click a button, then serverside you have coded what should happen when a button gets clicked for example turn text red. Then the server sends a new page with red text to the client (clientside...

I need to get a server side button to run this client side code?
I need to get a server side button to run this client side code when the server button is clicked and then subsequently called by the server. Is it possible? The problem is that the print control is a client side activex. I can call it normally using a client side button but this is no good when I need to print more then one page. Any help would be great. Thanks. The code: function PrintProc(){ var MyPrinter; MyPrinter = new ActiveXObject("ImgXPrint6.ImgXPrint"); MyPrinter.PageFrom = 1; MyPrinter.PageTo = 1; MyPrinter.PageM...

server side controls in a non-server side form
I want to use server side controls in a non-server side form.I use server side controls (like dropdownlists) so I can fill them with the right options from the database.My question is, what is the best way to approach this?CAN I use server-side controls in a client side form? If so, how can I get the values contained in the controls when I do a post? (not in a querystring).Here's a sample of my code: <form id="frmAdvancedSearch" method="post" action="advancedSearch.aspx"> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <input type="submit" /> </form>...

how do i get selectedValue of drop down list server side if i am populating it using client side javascript?
 Hi All.I am populating a drop down list client side using: The drop down list is populated based on a selection of another drop down list. ddlList.options[i] = new Option(1,2); as an exampleThe populating is done as i need it to. However, a button click event i am trying to get the selectedValue of the ddlList. However, it doesn't give me it. It only gives me the selectedValue of the drop down list on first rendering. Any ideas on how i can get it?   Could You paste some code? That would be helpful. Thanks S@ss (Shashi Shekhar Singh)My BlogPlease mark a post as ANSWER ...

Web resources about - How to get innerText from IFrame (on server-side / on client-side) - asp.net.web-forms

Server-side scripting - Wikipedia, the free encyclopedia
... unfocused, scattered, unnecessary details. WikiProject Technology or the Technology Portal may be able to help recruit an expert. Server-side ...

Google Cloud Platform simplifies server-side development for iOS w/ ‘Mobile Backend Starter’
... Mobile Backend Starter that first debuted for Android developers back in June. Google says the application helps to simplify the server-side ...

Free Cooling: the Server Side of the Story
Servers that support higher inlet temperatures could significantly reduce or even eliminate the cooling costs of the data center. We received ...


[Update: Check Now] Play Store For Android Gets Search Bar With Hamburger Flip In Server-Side Update
Google is pushing out an update to the Play Store's Android interface that replaces the action bar with a standard search bar. Inside are the ...

Server-side update makes Siri a stickler for succinctness
Siri is already well known for her wit and willingness to joke, but a recent server-side update has given Apple's digital assistant the ability ...

Japanese RIAA wants server-side music DRM for mobile phones
The Recording Industry Association of Japan—the Japanese version of the RIAA— …

New BaaS platform aims to eliminate writing server-side code
... offering for desktop and mobile developers that's now leaving its beta phase. By removing the need for writing code on the server-side, Backendless ...

Dart improves async and server-side performance
... Team Today's release of the Dart SDK version 1.3 includes a 2x performance improvement for asynchronous Dart code combined with server-side ...

Customize Google Using Server-Side Scripts
Google's services have a lot of powerful features, but they can't offer all the options requested by users. A popular way to customize Google ...

Resources last updated: 2/16/2016 12:08:04 PM