i have a query
thr is one web page
and i am using two iframe in that
like equal partision of a page
and there are some contents , words , text which are same in both parts
and if i am selecting any one word or sentence which are also in second part will be highlight
I don't think there is a way to select web page content via JS. You might be able to do this if it were just text in a textbox or something similar.
UPDATE
As is usually the case, I was proven wrong :) Check out Marcel's posted function. This function appears to select content between two object. You'll just need to do this twice (one for each frame object), rather than once using the document object
selecting text by ignoring inner Elements of div tag javascript
Related
I have designed a page to be used as a tool. I am getting some challenges here since my experience is very little in the field and im only new.
- my goal is to change values of an element on a page that is not open yet.
- is there a function i can make on current page to change the values of the element on the next page to preset it to some static numbers or some of them are dynamic
I dont know how to manipulate something that is not open yet, i dont even know if that's something possible. I was able to change elements on my open current page, but dont know how to change something on the next page if i click on one of the links
Park Property Management
Millgate Manor
Weston Towers
Kingston
Region Of Peel
so i expect to click on one of the links and when the link opens some elements in the links i need them to be filled with some values that are static always
You can't directly influence the content of another page with JavaScript in the current page. That would have very big security concerns.
However, you could indirectly influence the content if you have access to the source for both pages, and can add JavaScript to both of them. Then, as some comments suggested, you can for example use search paramaters in the link url to pass along information.
(Search parameters are the stuff that comes at the end of a url sometimes and looks something like ?name=john&id=555)
You can read more about about working with search parameters in JavaScript here:
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
Don't get discouraged! You're capabilities will grow as you try to make things work. (That's almost the only time they will grow.)
A word of caution!
Please be very careful when using search parameters to modify or display content on a page as there are some real security concerns involved. Never display anything from the search parameters directly on the page without validating the input first. A good way to handle dynamic content based on search parameters, at least if you know the possible options available, is to have some if .. else statements or maybe a switch block that you try to match the search parameters against, and simply not display anything at all if the content of the parameter does not match any input that you're expecting.
am looking forward for a solution to the following problem
i do have one i frame in my web page which refers to the content of yet another page.My problem is that i need change the content of the i frame upon the text box value. so i decided to pass the value of my text box as query string parameter
like
src="E/Ess/Application_form1.aspx?USER=document .getElementById(TXTCODE).value ">
with in my I frame.
but it seems it doesn't work any more.. i have tried java script function also ?expecting a reasonable solution
I have a web page that draws data from several other local (same origin) web pages. I collect the data from these other web pages using XMLHttpRequest. I then use the DOM to parse out the needed data from each page. There is one piece of data that I would like to include in each of the other local pages (i.e., in the DOM for each of the other local pages), however, I don't want that data visible when the web page is viewed. (Visible in the source code is OK, just not in the rendered HTML). I can think of a couple of ways of doing that. However, I am not enammered with any of them. I'm wondering what suggestions others might have. Thanks for any input.
Some options:
The hidden attribute:
All HTML elements may have the hidden content attribute
set. The hidden attribute is a boolean attribute. When
specified on an element, it indicates that the element is not yet, or
is no longer, directly relevant to the page's current state, or that
it is being used to declare content to be reused by other parts of the
page as opposed to being directly accessed by the user. User agents
should not render elements that have the hidden attribute
specified.
The template element
The template element is used to declare fragments of HTML that
can be cloned and inserted in the document by script.
In a rendering, the template element represents nothing.
Comments
Depending on the semantics, you can choose one or another. Or even combine them:
<template hidden><!-- Hidden data --></template>
As you mentioned to get through AJAX request, it is in your control where to show or not.
Once you get the result through AJAX, you can store in your script to do some manipulation or show in HTML page itself with parent tag as visible false, so that end user cannot see (except Source code viewing).
What's wrong with a simple hidden div?
<div id="hiddenData" style="display:none;">...</div>
To be honest, it seems like the way you are passing around data is kind of a hack already, so I don't see any real need to be fancy.
What I'm trying to do is allow the user to select a piece of text on the page and highlight it, then be able to load this selection and re-highlight it on further visits (with purely client side JavaScript, I intend to package this into a Chrome extension in future).
I am selecting the text with window.getSelection, but AFAIK this doesn't give me any kind of index or placement data about the selected text (or element).
The only way I can currently think of is to record the actual text and search for it, but this raises the problem of uniqueness (the same string of text is likely to appear multiple times on a given page). Is there a way of traversing the DOM tree upwards and storing the 'path' to the containing element (and then only having to worry about uniqueness within that one element)? I'd be happy with that if there isn't a better way.
Thanks
Edit: what I am doing right now is something similar to this: http://jsfiddle.net/e3XX6/
Have you examined the selection object returned by the getSelection() method? For example, it has an anchorNode property that in turn has a parentElement property. That last property will tell you the element that contains the text.
See this version of your fiddle (open your console!): http://jsfiddle.net/e3XX6/1/
Also, since you're going to make this a Chrome Extension, I'd just recommend using HTML5 Web Storage to remember the selection.
It's been a while since I last did coding, I was just wondering how simple I could make this little idea of mine.
Simply put, I'd like to have 4 input text fields on one page, an example of the label and text field is: http://www.url.com/[ASpecificLink] where the [] denotes Text Fields. Upon filling all the text fields and clicking 'Okay', the next page will list iFrames of the link specified, making it a total of 4 iFrames on one page.
My first question is : How simple could I make this idea? off the bat I thought of using PHP, ideally i'd like to access this on an iPad.
My second question is : Would it be possible, for example, to list specific content in the iFrames. For example, in the link I enter, the only content I would like to show is what is contained within the Table elements of the whole page (this would mean the top banner, navbar and other elements would be excluded)
Thank you very much, and looking forward to some other perspectives on this idea. My approach might not be the most efficient way to go about this, and therefore I'd appreciate some out-of-the-box opinions.
Thank you very much
As for the first question : it is very simple to do, but you should'nt use PHP. This can be done very easily with Javascript :
Create a new IFrame element
Set the "src" property to the content of the text inputs
Append it to the page
The browser will load the pages in the iframes by itself.
As for the second question :
Load the page using AJAX (Javascript)
Get the elements you want from the page with Javascript
Append them to an IFrame's ContentWindow property
No code here, since you seem to be only expecting ideas of implementation options :-)