Text highlighting

Using text highlighting within content changing iframe.

Page 1 of 1

0 Replies - 744 Views - Last Post: 07 July 2009 - 10:05 AM

#1 s_kucksdorf   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 69
  • Joined: 12-May 09

Text highlighting

Posted 07 July 2009 - 10:05 AM

Hi all,

I am having some trouble with a website. First off it is to display documentation for some software that is developed here. What the basic page is, is 2 iFrames, one that acts like a table of content and the second displays whatever link you click on within the table of content. Then there are 7 buttons, Print (only the 2nd iframe content), first, back, next, and last (move to their respective pages within the table of content), search (brings up a modal popup extender that allows a search to be performed) and show all refreshes the page back to it's normal self (I change the way the page looks upon a search).


Anywho, my problem is, while the search is functional my employeer would like me to search through the content of the iframe and highlight any the text that was searched for. I've tried using javascript and I cannot find a way to get a post load or post click event so I cannot read the new src for the iframe. ASP also failed for the same reason. Any suggestions would be appreciated.

I will also include my search function, however it uses txt files and then truncates the .txt and adds either .htm or .html. I know it's not the cleanest way to do it, but I wanted a easy search.



I want your opinion even if you don't know how to do this. Mostly I want to know if it is possible. I have been working on this for 12+ hours by now.




The following is ASP:
Dim searchSucess As Boolean = False
lblSearchLinks.Text = ControlChars.NewLine + "<script type=""text/javascript"">var searchString = """ + txtSearchString.Text().ToUpper() + """</script>" + ControlChars.NewLine
Dim searchString As String = txtSearchString.Text().ToUpper()
If searchString.Length > 0 Then
	toc.Visible = False
	pnlSearch.Visible = True
	Dim tempList As Node = fullList
	While Not tempList Is Nothing
		Dim strLocation As String = HttpContext.Current.Server.MapPath("~/Users/Manual_Files/" + tempList.info)
		Dim sr As New StreamReader(strLocation)
		strLocation = strLocation.Remove(strLocation.IndexOf("."), strLocation.Length - strLocation.LastIndexOf("."))
		Dim strDocument As String = sr.ReadToEnd().ToUpper()
		Dim strRelativeLoc As String = "Manual_Files" + tempList.info.Replace("\", "/")
		strRelativeLoc = strRelativeLoc.Remove(strRelativeLoc.LastIndexOf("."), strRelativeLoc.Length - strRelativeLoc.LastIndexOf("."))
		Dim strName As String = strRelativeLoc.Remove(0, strRelativeLoc.LastIndexOf("/") + 1)
		If strdocument.Contains(searchString) Then
			If File.Exists(strLocation & ".htm") Then
				strRelativeLoc = strRelativeLoc + ".htm"
			ElseIf File.Exists(strLocation & ".html") Then
				strRelativeLoc = strRelativeLoc + ".html"
			End If
			lblSearchLinks.Text += "<a href=""" + strRelativeLoc + """ target=""Manual"" onclick=""highlight('" + strRelativeLoc + "')"">" + strName + "</a><br/>" + ControlChars.NewLine
			searchSucess = True
			btnShowAll.Enabled = True
			Response.Cookies("Search").Value = "True"
		End If
		tempList = tempList.after
	End While
	If Not searchSucess Then
		Response.Cookies.Add(New System.Web.HttpCookie("Search", "False"))
		lblSearchLinks.Text = "The search did not find anything."
	End If
End If


This post has been edited by s_kucksdorf: 07 July 2009 - 11:46 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1