Page 1 of 1

Iframe, XML

Posted: Thu Aug 18, 2005 5:26 pm
by raghavan20
hi guys, I have got two files
a. http://www50.brinkster.com/raghavan20/a ... /news.html
b. http://raghavan20.allhyper.com/xmlParser.php

my brinkster account allows only asp files and i have got my personal site, so i want this news feed in there.
for the sake of running php, i run it from another account.

now, the xmlparser.php gets the rss source parses it and displays as html in a div in the same file.
the news.html has an iframe with the src as http://raghavan20.allhyper.com/xmlParser.php
alright, now i try to send the content of the div in xmlParser.php to its parent news.html every 2 sec.
now, the problem is, it does not call the function in the parent window to load the messages into the appropriate div in the news.html

if you go to http://www50.brinkster.com/raghavan20/a ... /news.html,
for your understanding, i have made the iframe visible so you can see the contents coming from.
you would be alerted twice of a function called in xmlParser.php which tries to send content to news.html.
now, help me find out why the function in parent window, news.hmtl is not called.

necessary piecesof codes
news.html, parent window

Code: Select all

<body>
<div class="header">
<img src="banner.gif" style = "width:100%; margin:0px; padding:0px;"/>
</div>
<div id = "mainMmenu" style="border:1px solid #000000; text-align:center ">
	<span class="menu"><a href="aboutMe.html" class="menu">About Me</a></span>
	<span class="menu"><a href="default.asp" class="menu">Home Page</a></span>
	<span class="menu"><a href="generalLinks.asp" class="menu">General Links</a></span>
	<span class="menu"><a href="news.php" class="menu">News</a></span>
	<span class="menu"><a href="http://raghavan.allhyper.com/index.php" class="menu">Blogs</a></span>
	<span class="menu"><a href="http://raghavan20.allhyper.com/index.php" class="menu">Chat</a></span>
	<span class="menu"><a href="employers.html" class="menu">Employer's section</a></span>
	<span class="menu"><a href="xml.php" class="menu">XML</a></span>
</div>
<div class ="parent">
	<div class="mainDiv" id="mainDiv">
		<iframe src="http://raghavan20.allhyper.com/xmlParser.php" style="width:100%; height:100%; overflow:inherit;"></iframe>
	</div>
	<div class="subNav">
		<div id ="subMenu">
		</div>
	</div>
</div>	
<div id="clearfooter"></div>

<script language="javascript">
	function loadContent(content){
		alert ("loadcontent called:" + content);
		document.getElementById("mainDiv").innerHTML = content;
	}
</script>
</body>
xmlParser.php, the child window

Code: Select all

<html>
<body>
<div id = "content">

Code: Select all

<?php
//xml parsing code is not provided here
$xml_parser = xml_parser_create(); 
$rss_parser = new RSSParser(); 
xml_set_object($xml_parser,&$rss_parser); 
xml_set_element_handler($xml_parser, "startElement", "endElement"); 
xml_set_character_data_handler($xml_parser, "characterData"); 
$fp = fopen("http://www.rediff.com/rss/newsrss.xml","r") 
or die("Error reading RSS data."); 
while ($data = fread($fp, 4096)) 
xml_parse($xml_parser, $data, feof($fp)) 
   or die(sprintf("XML error: %s at line %d",  
	   xml_error_string(xml_get_error_code($xml_parser)),  
	   xml_get_current_line_number($xml_parser))); 
fclose($fp); 
xml_parser_free($xml_parser);

?>

Code: Select all

</div>
<script language="javascript">
	setTimeout("getContent()", 2000);
	function getContent(){
		alert ("get content called");
		alert (document.getElementById("content").innerHTML);
		parent.loadContent(document.getElementById("content").innerHTML);
		window.location = "xmlParser.php";
	}
</script>
</body>
</html>

Posted: Thu Aug 18, 2005 8:14 pm
by raghavan20
I have uploaded the same news.html file into the same server where parseXML is. now, everything works fine.
but I dont understand if the parent window is in another server cant the child communicate with the parent???
have a look at: http://raghavan20.allhyper.com/news.html
anybody pls help me with the height property :cry: its horrible!!!