Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript
|
BOOK: Beginning JavaScript
This is the forum to discuss the Wrox book Beginning JavaScript by Paul Wilton; ISBN: 9780764544057
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 7th, 2007, 03:09 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem updating iframe content from server side

Hi all i am using iframe to display some dynamic data and i make frequent request to server to see if new data is avaliable .But the problem is that aftr i manually update the iframecontent.php i do not see the changes on my main page !!If i hit f5 i see the change. could any one tell me why my code does not update it automatically without refreshing the whole page. i frequently call getnewdata()
to fetch new data but it never updates the iframe display. I did lot of search to find out what is wrong but could not fix the problem so i be happy if some one help me fix it.Thanks

data output on screen : But it never change even when i update iframecontent.php manually and make frequen call to it!!
http://img3.freeimagehosting.net/uploads/c0411a81e9.jpg


iframe inside javascript:

Code:
<div id="text" style="z-index:90;" class="chatWindowTextDisplay"
title="Chat Transcript - "
alt="Chat Transcript -"
><iframe name="textFrame" id="textFrame" src="http://localhost/ajaxWithoutHTPrequest/iframe/iframeContent.php?cmd=file&file=chatTemplate&template=chatText&amp;site=676789&amp;sessionkey=H9030219168890559071K46359640" frameborder="0" border="0" width="350" height="220" class="chatWindowTextFrame"
title="Chat Transcript - "
alt="Chat Transcript - "
>This functionality requires frames. </a>.</iframe>
</div>


<script type="text/javascript">

document.getElementById("text").tabindex = 3;
document.getElementById("textFrame").tabindex = 3;

</script>
<script type="text/javascript">

document.writeln('<div id="hiddentext" style="z-index:0;position:absolute;visibility:hidden;left:0;top:13px">'+
    '<iframe name="lpCommFrame" id="lpCommFrame" src="http://localhost/iframecontent.php" frameborder="0" border="0" width="350" height="220" title="Background">'+
    'This functionality requires frames. </iframe>'+
'</div>');

function getnewdata()
{
var u = "http://localhhost/iframecontent/?cmd=file&file=chatText&site=676789&sessionkey=H7221484707459237529K46228278&d=" + jsGetDate();
        document["lpCommFrame"].location = u;
jsCheckCommFrame();

}

function jsGetDate()
{
    var d = new Date();
    return d.getTime();
}

function jsCheckCommFrame() {

//alert("jscheckcommframe");

    var win = window.frames['lpCommFrame'];
    try{
        if ((typeof(win) == "undefined") || (win.document.body == null) || (typeof(win.document.body) == "undefined"))
            return;
    }catch(e){
        reportError(e,'jsCheckCommFrame_win');
        return;
    }

    //test for server error
    var newtext = win.document.body.innerHTML;
    if ( newtext!=null && typeof(newtext)!="undefined" && (newtext!="")) {
        var controlmsg = newtext.substring(0,10);
        if (controlmsg == "<br>Server") {
            lpOnSendTextFail( lastText, 1);
            return;
        }
    }

    var textArray = win.chatLines;
    if(textArray==null) return;
    var lineCount = textArray.length;
    if (lineCount != prevLineCount) {
        prevLineCount = lineCount;

        //convert chat array
        var chatLines = new Array();
        for(iline=0;  iline<lineCount;  iline++){
            var jLine = textArray[iline];
            if(jLine.length!=4) continue;
            chatLines[iline] = new LPChatLine( jLine[0], jLine[1], jLine[2], jLine[3] );
        }
        if( lpLastLineIndex != chatLines.length ) {
            lpOnAddLines( chatLines, lpLastLineIndex );
            lpLastLineIndex = chatLines.length;
        }

        unsentLine = "";
        // If we have unsent lines because we switched from Java to Javascript - send the next line.
        if (sendingUnsentLines){
            sendUnsentLines();
        }
    }

    //push url
    var pushURL = win.pushURL;
    win.pushURL = "";
    if (pushURL != "") {
        lpOnURLPush(pushURL);
    }

    //handle control command
    var controlCommand = win.controlCommand;
    win.controlCommand = "";
    if ((typeof(controlCommand) != "undefined") && (controlCommand != null) && (controlCommand != "")) {
        handleControlCommand(controlCommand);
    }

}

<script>
iframecontent.php:

Code:
<?
  Header('Cache-Control: no-cache');
  Header('Pragma: no-cache');
  ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="EN" xml:lang="EN">
<head>

<link href="./window.css" rel="stylesheet" type="text/css" />


<title>Window</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="description" content="Live " />
<meta name="keywords" content="live" />
<style>
BODY {
  width:334px
}
</style>
</head>
<body bgcolor="white" style="margin: 0" onload="scrollwindow()" class="contentWrapper">
<script type="text/javascript">
var chatLines = [["I am testing this i frame","Bob","4","1175958864183"],
["i do not know how this is working","Bob","1","1175958880480"],
["could any one tell me","Bob","1","1175958883949"]
];
function scrollwindow()
{
    if ((navigator.appName.indexOf("Netscape") < 0) || (parseInt(navigator.appVersion)>4))
        scroll(0, 50000);
}

var wasInChat = true;
var pushURL = "";
var controlCommand = "";
document.controlCommand = controlCommand;

if (navigator.appName.indexOf("Netscape") >= 0)
    scroll(0, 50000);

</script>
<noscript><p>
This functionality requires JavaScript. Please enable JavaScript and try again.

</noscript>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
  <td dir="ltr" class="chatContent">
       <div id="chatContentDiv" style="font-size: smaller; font-family: arial, arial, helvetica, geneva;">
    <span style="color: blue;"><b><span class="OperatorName">Bob: </span></b></span>
<span style="color: black;"><span class="OperatorText">I am testing this i frame</span><br /></span>
<span style="color: blue;"><b><span class="OperatorName">Bob: </span></b></span>
<span style="color: black;"><span class="OperatorText">i do not know how this is working</span><br /></span>
<span style="color: blue;"><b><span class="OperatorName">Bob: </span></b></span>
<span style="color: black;"><span class="OperatorText">could any one tell me</span><br /></span>

    </div>
  </td>
</tr>
</table>
</body>
</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Converting Client-side to Server-side Code kwilliams ASP.NET 2.0 Professional 1 November 21st, 2007 05:25 PM
Problem with iframe content when refreshing page klax Javascript 0 April 21st, 2007 04:43 PM
Firing server side events at client side codes mehdi62b ASP.NET 1.0 and 1.1 Basics 6 May 18th, 2005 09:11 AM
Client & Server Side Scripting Problem lbob Classic ASP Professional 0 October 16th, 2003 10:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.