How to highlight some text in an iframe by script?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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".
 
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
| >
| >
| >
 
Back
Top