The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> IE vs Other browsers executing javascrip, IE runs JS only once, while other browsers every time
Bob Miers
post Mar 10 2012, 09:08 AM
Post #1





Group: Members
Posts: 6
Joined: 10-March 12
Member No.: 16,677



I would be extremely grateful if you could cast your eye over the following problem and give me some advice if possible.

I have a WEB site index.html page (www.woodmereassociates.com) that uses the following code to read and
display a normal text file. (I found this code on the WEB)
It works as advertised, quite well, with all of the browsers (Foxfire,
Apple's, etc.) I've tested except with MS IE8 & IE9 and maybe earlier versions as well.

When I access the WEB page by entering the URL in the address line, I see the context of the text file as desired.
However if I navigate to any other page on the WEB site and then return to the Home Page (index.html),
the text file content is not shown.

My bypass is to use the text "id="dsp">Check with
one of our agents for Our Featured Listing particulars." text is used within the html code. (see code near the end).

Thinking that this might be a cache problem, I've tried several methods to make the browser not reuse cache, but to no
avail. ie <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">

Any ideas?

If need be I can post the entire page.

Thanks, Bob Miers

<!--this is the beginning of the code to read a text file
-->
<!-- <meta http-equiv="content-type"
content="text/html;charset=utf-8" />
<title>An XHTML 1.0 Strict standard template</title>
<meta http-equiv="content-type"
content="text/html;charset=utf-8" />
-->
<script type="text/javascript">
//<![CDATA[
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope
with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
alert('!IE')
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}
xmlhttp.open("GET","featured.txt" ,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.getElementById('dsp').innerHTML=xmlhttp.responseText;
}
}
xmlhttp.send(null)
//]]>
</script>
<!--</head>-->
<!--<body>-->
<div>
<div>
<p align="justify" id="dsp">Check with one of our agents
for Our Featured Listing particulars.</p>
</div>
</div>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 10 2012, 09:35 AM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Does this happen only in IE or what?

What is the text that is displayed this way? I don't think I see it at all. Turning JavaScript off makes no difference. And I certainly don't see your fallback text (Check with one of our agents... ).

Also, why is the text in question included this why? I guess it's something that's updated often, but why not a normal include (SSI, PHP)? Maybe I'll understand that once I know what the text is though.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 10 2012, 10:39 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



Seems to work in my IE emulator (all IE versions) when I put the p#dsp element before the script instead of after (you might also wrap the whole script in an onload event).

BTW it seems Chrome/Iron's and Opera's default settings don't allow offline AJAX file inclusion, their error consoles saying "Cross origin requests are only supported for HTTP" and "XMLHttpRequest to files is disabled for security reasons", respectively.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 10 2012, 10:52 AM
Post #4


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Does FF? Because I didn't see anything in K-Mel either.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Bob Miers
post Mar 10 2012, 10:52 AM
Post #5





Group: Members
Posts: 6
Joined: 10-March 12
Member No.: 16,677



QUOTE(pandy @ Mar 10 2012, 07:35 AM) *

Does this happen only in IE or what?

What is the text that is displayed this way? I don't think I see it at all. Turning JavaScript off makes no difference. And I certainly don't see your fallback text (Check with one of our agents... ).

Also, why is the text in question included this why? I guess it's something that's updated often, but why not a normal include (SSI, PHP)? Maybe I'll understand that once I know what the text is though.



Thanks for the quick reply. I'll try and explain.

The actual owner of the site isn't all that computer literate, so I am working to make it easy for him to do the update.
Our current process is for him to prepare the "our listings" photo gallery with CoffeeCup software. He puts the photo and text that he wants to be the featured listing as the 1st photo. CoffeeCup then creates a SWF file that is controlled by a XML file. CoffeeCup has it's own FTP stuff that uploads all the photos and text. He has mastered that task.

He then notifies me and I look at the contents of the XML file for the 1st photo. I then copy and rename the correct photo to one called "featured.jpg", I also extract his text from the XML and put it into a normal text file called "featured.txt".

My goal is to write a PHP page that will do my part and give him access to that page while restricting everyone else.

I suppose that I could write code to do this every time the page is opened, but that seems to put more download time on the page. We only change the "featured" stuff every 4-6 weeks.

FYI the current Featured.txt content is: "122 E. Barrel Cactus Lane - $78,900 – MLS4722346 - One of the prime houses in Caliente Casa De Sol and in a prime location on the sunny side of the street. 1997 Cavco park model with extra nice 12X12 foot Arizona Room, dual pane windows, a 15X20 foot porch, AND! a covered lot with full concrete next door for your RV, finished shed/workshop"

Again, let me try and explain what I see. If I use Foxfire/Chrome etc., the above text shows up just below the mid page "Our Featured Listing" banner every time that I access the page. In IE it only shows up when the URL address is entered into the browser. If I navigate to any other page of the site and then return to the "Home" page, the default text shows up not the content of the text file.

I'm currently using IE9. But, earlier I looked at the code that IE had downloaded and the text file code wasn't there after return to the Home page from one of the other pages.

If you have ideas on a better method of accomplishing the update, please let me know.

If you would like I can capture the screen and attach. Let me know

Thanks again for your time.

Bob Miers
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 10 2012, 10:54 AM
Post #6


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Mar 10 2012, 03:35 PM) *

What is the text that is displayed this way? I don't think I see it at all.

It's the text below the "Our featured listings" image:
"122 E. Barrel Cactus Lane - $78,900 – MLS4722346 - One of the prime houses ..."

If you want to test offline you can simply make your own "featured.txt" file.
QUOTE
Turning JavaScript off makes no difference. And I certainly don't see your fallback text (Check with one of our agents... ).

Does for me...

QUOTE
Also, why is the text in question included this why? I guess it's something that's updated often, but why not a normal include (SSI, PHP)?

True. The advantage of AJAX is to include different server content depending on the user's actions (and without reloading the page in between), but for a static file include (like this appears to be), server-side includes with PHP or SSI is much more simple and reliable.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 10 2012, 10:55 AM
Post #7


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(pandy @ Mar 10 2012, 04:52 PM) *

Does FF? Because I didn't see anything in K-Mel either.

Both work for me.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Bob Miers
post Mar 10 2012, 10:57 AM
Post #8





Group: Members
Posts: 6
Joined: 10-March 12
Member No.: 16,677



QUOTE(Christian J @ Mar 10 2012, 08:39 AM) *

Seems to work in my IE emulator (all IE versions) when I put the p#dsp element before the script instead of after (you might also wrap the whole script in an onload event).

BTW it seems Chrome/Iron's and Opera's default settings don't allow offline AJAX file inclusion, their error consoles saying "Cross origin requests are only supported for HTTP" and "XMLHttpRequest to files is disabled for security reasons", respectively.



Just so I'm clear in my posting. The text file shows up when the URL is put into the browser, however, when returning to the Home page after visiting any other page, the default text shows up.

Thanks for all of you for your help.

Bob miers
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 10 2012, 11:08 AM
Post #9


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(Bob Miers @ Mar 10 2012, 04:57 PM) *

QUOTE(Christian J @ Mar 10 2012, 08:39 AM) *

Seems to work in my IE emulator (all IE versions) when I put the p#dsp element before the script instead of after (you might also wrap the whole script in an onload event).

Just so I'm clear in my posting. The text file shows up when the URL is put into the browser, however, when returning to the Home page after visiting any other page, the default text shows up.

With my offline test version, I get JS errors already from the first page load. After I put #dsp before the script, it works even after going back from another page.

The reason it works for you on the web might be due to the delay before the server sends the text file (giving the script time to "discover" #dsp? unsure.gif ), and for the same reason it may not work once the text file has been cached. In any case, try placing #dsp before the script.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 10 2012, 11:08 AM
Post #10


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Oh, I do see it! I must have missed it before. I see your fallback text also. Odd, I used Find and searched for one of the words and it wasn't there. Maybe I was clumsy and made a typo.

OK, so basically the script just includes the text? Or does it process it in some way? Because if it doesn't I'd use a normal include and don't have to worry about JavaScript and browsers.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Bob Miers
post Mar 10 2012, 11:28 AM
Post #11





Group: Members
Posts: 6
Joined: 10-March 12
Member No.: 16,677



QUOTE(pandy @ Mar 10 2012, 09:08 AM) *

Oh, I do see it! I must have missed it before. I see your fallback text also. Odd, I used Find and searched for one of the words and it wasn't there. Maybe I was clumsy and made a typo.

OK, so basically the script just includes the text? Or does it process it in some way? Because if it doesn't I'd use a normal include and don't have to worry about JavaScript and browsers.


Yes, all that I want the script to do is put it on the page - it doesn't do any processing of the text.


If you have the time and inclination, please explain what you mean by "include" and if possible give me an example. I'll also do a bit of study on my part.

Bob Miers
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Mar 10 2012, 12:18 PM
Post #12


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



There are various ways to include the content of another file using server-side processes. Please see the FAQ entry How do I include one file in another?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 10 2012, 12:24 PM
Post #13


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



It's very easy, a kind of server side Find & Replace. If you already use PHP or plan to, that's what you should use for this too. Otherwise SSI (Server Side Includes) is (are? tongue.gif) available on most servers.

In the case of SSI you just use a "special tag" where you want the text file to be included and the server will replace this tag with the content of the text file before the page is served. You must also make the server parse your pages for SSI, but that's no biggie either. I leave out the details for now.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Bob Miers
post Mar 11 2012, 11:20 AM
Post #14





Group: Members
Posts: 6
Joined: 10-March 12
Member No.: 16,677



Hi all
Just a quick followup to this problem. I did my study on SSI and was able to get it to work within Dreamweaver (the editor that I use) but when uploading to the host, it didn't work. So after more research, I was able to enable the SSI on the host. Now, even with IE, the text file content is shown.

Thanks to all for your time and knowledge for point me in the correct direction.

Bob Miers
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Mar 11 2012, 11:43 AM
Post #15


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



You're welcome. Good it worked out. smile.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Bob Miers
post Mar 12 2012, 03:22 PM
Post #16





Group: Members
Posts: 6
Joined: 10-March 12
Member No.: 16,677



QUOTE(pandy @ Mar 11 2012, 09:43 AM) *

You're welcome. Good it worked out. smile.gif


Have you ever looked at the Registration Form code found at this site:

http://www.html-form-guide.com/php-form/ph...5#comment-36017

It seems to be straight forward, however after creating the database on my hosting company (1and1.com) and putting the info into the fm_membersite.php file, I get an error that I can't open the database.

Thanks

Bob Miers
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 18th April 2024 - 01:08 PM