Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Complicated HTML Problem
#12
(12-19-2009, 03:08 PM)Rob Wrote: Could you give me an example of some code I would use?

So here you go, there is a php script that loads the content of a given website, in this case it's a google.com

PHP Code:
<?php

$content 
file_get_contents("http://www.google.com/");

$matches null;

preg_match_all("/<title>(.*?)<\/title>/"$content$matches);

echo 
$matches[1][0];

?>

The preg_match function will search for the title of the loaded content and it will echo it
Now the ajax, the code is taken from w3 and I edited few lines...

Code:
<html>
<body>

<script type="text/javascript">
function ajaxFunction()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  document.getElementById("content").innerHTML=xmlhttp.responseText;
  }
}
xmlhttp.open("GET","extern.php",true);
xmlhttp.send(null);
}
</script>

<div id="content" onclick="ajaxFunction();">
a
</div>

</body>
</html>


When you click on the div, the ajaxFunction will load extern.php.... and update the inner html of the div.


Messages In This Thread
Complicated HTML Problem - by RPicard - 12-19-2009, 02:05 PM
RE: Complicated HTML Problem - by Grizzly - 12-19-2009, 02:13 PM
RE: Complicated HTML Problem - by RPicard - 12-19-2009, 02:15 PM
RE: Complicated HTML Problem - by Grizzly - 12-19-2009, 02:19 PM
RE: Complicated HTML Problem - by RPicard - 12-19-2009, 02:20 PM
RE: Complicated HTML Problem - by Gaijin - 12-19-2009, 02:24 PM
RE: Complicated HTML Problem - by RPicard - 12-19-2009, 02:29 PM
RE: Complicated HTML Problem - by Gaijin - 12-19-2009, 02:40 PM
RE: Complicated HTML Problem - by RPicard - 12-19-2009, 02:44 PM
RE: Complicated HTML Problem - by Gaijin - 12-19-2009, 02:49 PM
RE: Complicated HTML Problem - by RPicard - 12-19-2009, 03:08 PM
RE: Complicated HTML Problem - by Gaijin - 12-19-2009, 03:14 PM
RE: Complicated HTML Problem - by Grizzly - 12-19-2009, 03:15 PM
RE: Complicated HTML Problem - by RPicard - 12-19-2009, 03:15 PM
RE: Complicated HTML Problem - by Grizzly - 12-19-2009, 03:33 PM
RE: Complicated HTML Problem - by RPicard - 12-19-2009, 03:59 PM
RE: Complicated HTML Problem - by Gaijin - 12-19-2009, 09:47 PM
RE: Complicated HTML Problem - by Muzen - 12-20-2009, 03:00 AM
RE: Complicated HTML Problem - by RPicard - 12-20-2009, 07:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Contact form for HTML Crystal 36 10,918 05-24-2013, 05:51 PM
Last Post: Akai
  Helping with HTML and CSS Ambitious 0 697 08-28-2011, 01:18 PM
Last Post: Ambitious
  Anyone have any free HTML resources? Scalise 7 1,771 06-01-2011, 04:00 AM
Last Post: !LoL
  Mr. Doob :: HTML 5 Examples Gaijin 10 2,571 02-17-2011, 12:33 AM
Last Post: Gaijin
  My first HTML / CSS project. Jordan L. 11 1,707 04-09-2010, 09:44 AM
Last Post: Jordan L.

Forum Jump:


Users browsing this thread: 2 Guest(s)