How to highlight some text in an iframe by script?

G

Guest

hi, all
I have an iframe in my page. Actually what I want is just like the google
search.
When user clicks search, I will load the a page from another URL into iframe
and then highlight the key words in the iframe.
Does anyone know how to do this? By JS or VBScript?

Thanks
 
E

Eliyahu Goldin

If you look at the HTML source of a google search page with highlighting,
you will find that the highlighted words are enclosed by <b> tags. I assume
they loop through all elements on the page to find the words to highlight,
i.e. to enclose with <b>, in the element's innerText property.

Eliyahu
 
G

Guest

Thanks for your reply.
Now I got a problem when I try to loop through all elements. How to get
these? I tried :
str = window.frames['myframe'].body.innerHTML
and it tells me "Can not access", or "Access is deny".
 
B

bruce barker

this cannot be done with javascript due to security issues. javascript code
can only access windows loaded from the same site. you will have to use the
google approach. rather than an iframe, their website fetches the page,
modifies the content, then returns it with google headers and footers. see
the webclient class.

-- bruce (sqlwork.com)



| Thanks for your reply.
| Now I got a problem when I try to loop through all elements. How to get
| these? I tried :
| str = window.frames['myframe'].body.innerHTML
| and it tells me "Can not access", or "Access is deny".
|
| "Eliyahu Goldin" wrote:
|
| > If you look at the HTML source of a google search page with
highlighting,
| > you will find that the highlighted words are enclosed by <b> tags. I
assume
| > they loop through all elements on the page to find the words to
highlight,
| > i.e. to enclose with <b>, in the element's innerText property.
| >
| > Eliyahu
| >
| > | > > hi, all
| > > I have an iframe in my page. Actually what I want is just like the
google
| > > search.
| > > When user clicks search, I will load the a page from another URL into
| > iframe
| > > and then highlight the key words in the iframe.
| > > Does anyone know how to do this? By JS or VBScript?
| > >
| > > Thanks
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,167
Latest member
SusanaSwan
Top