JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 31st, 2012, 12:23 PM
software2007 software2007 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 software2007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 39 sec
Reputation Power: 0
How can I load an external static html file to a JavaScript var?

I am new to JavaScript. I would like to use a small routine within my iOS project to search html file using javaScript.

Let's say I have "test.html" that I would like to search for a "phrase".

Is there a way to load the file into a var?
I know I can use getelementbyID(..) for some controls. But, how to do it for a static file?
The goal for me is to highlight certain words/text within the html document - I figured HTML can't do it, but javaScript would allow me.

Thanks

Reply With Quote
  #2  
Old December 31st, 2012, 01:13 PM
E-Oreo's Avatar
E-Oreo E-Oreo is online now
Lost in code
Dev Shed God 7th Plane (8000 - 8499 posts)
 
Join Date: Dec 2004
Posts: 8,054 E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)E-Oreo User rank is General 92nd Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 2 Months 1 Day 5 h 32 m 5 sec
Reputation Power: 7104
If the HTML file is on the same domain as the page hosting the JavaScript then you can use an XHR to retrieve the HTML contents of the file. I'm not sure how this works within the context of an iOS app.
__________________
PHP FAQ
How to program a basic, secure login system using PHP
Connect with me on LinkedIn


Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #3  
Old January 2nd, 2013, 03:37 PM
portcitysoftwar portcitysoftwar is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 163 portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level)portcitysoftwar User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 13 h 18 m 54 sec
Reputation Power: 17
Personally when i want to include another HTML page to play with through javascript i will use a hidden iframe. Im sure there are better ways to do this but it is how are company does it.
Code:
<iframe id="SomeHtml" src="somehtml.html" style="display:none">

This will allow the contents of somehtml.html to be accessible by javascript through

Code:
document.getElementById('SomeHtml').ContentWindow.document.body.innerHtml


It will also be completely invisible on the html page

Quote:
Originally Posted by software2007
I am new to JavaScript. I would like to use a small routine within my iOS project to search html file using javaScript.

Let's say I have "test.html" that I would like to search for a "phrase".

Is there a way to load the file into a var?
I know I can use getelementbyID(..) for some controls. But, how to do it for a static file?
The goal for me is to highlight certain words/text within the html document - I figured HTML can't do it, but javaScript would allow me.

Thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > How can I load an external static html file to a JavaScript var?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap