/    Sign up×
Community /Pin to ProfileBookmark

javascript buttons to call web page into div

Hi,
I am trying to create a page so that when the user clicks a button (i.e. Lunch menu) it calls up the lunch.htm page and places it in a specific div, lets call it main.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>crmenuonlline</title>

<style type=”text/css”>

#wrapper {

overflow:auto;
width:960px;
margin-right:auto;
margin-left:auto;
margin-top:50px;

}

#banner {
float:left;
background-color:red;
color:blue;
width:300px;
height:160px;
clear:both;

}

#restuarant {
float:right;
background-color:#00FF33;
width:660px;
height:160px;
}

#nav {
width: 100%;
float: left;
margin: 0 0 3em 0;
padding: 0;
list-style: none;
background-color: #f2f2f2;
border-bottom: 1px solid #ccc;
border-top: 1px solid #ccc; }
#nav li {
float: left; }
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #069;
border-right: 1px solid #ccc; }
#nav li a:hover {
color: #c00;
background-color: #fff;

#main {
float:left;
width:960px;
height:auto;
}

</style>

</head>

<body>

<div id=”wrapper”>

<div id=”banner”>CRmenuOnline.com</div>
<div id=”restuarant”>Rest Picture goes here</div>
<div id=”menu”>
<ul id=”nav”>
<li><a href=”#lunch.htm”>Lunch</a></li>
<li><a href=”#”>Dinner</a></li>
<li><a href=”#”>Appetizers</a></li>
<li><a href=”#”>Hours</a></li>
<li><a href=”#”>Location</a></li>
<li><a href=”#”>Simmilar Restaurants</a></li>
</ul>
</div>
<div id=”main”>Menu goes here</div>

</div>

</body>
</html>

What would be the best way to call up the web page using client side?
Javascript, PHP?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Ay__351_eFeb 06.2012 — I don't know php.

http://api.jquery.com/load/

Example: Load the feeds.html file into the div with the ID of feeds.

$("#feeds").load("feeds.html");

Result:

<div id="feeds"><b>45</b> feeds found.</div>
[/quote]


I try this. It is working in Firefox 4.0b9.
<br/>
&lt;html&gt;
&lt;head&gt;

&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.js"&gt;&lt;/script&gt;

&lt;script type="text/javascript"&gt;
// http://api.jquery.com/load/
// http://www.alixcan.net/jquery-ajax/jquery-load-fonksiyonu-ile-baska-dosyadan-veri-cekmek.html

$(document).ready(function(){
$('#lunch').click(function(){
var myid = $(this).attr('id');
alert(myid);
var h = myid +'.htm';
alert(h);
$('#mydiv').load(h);
// alert(document.body.innerHTML);
});
});

&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input type="button" id="lunch" value="lunch"&gt;
&lt;div id="mydiv"&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@shark1956authorFeb 08.2012 — Hi,

Thank youi for your help.

Here is my new problem.

Why does it pull up an alert box 2x with an Ok before it displays the page.

Again, Thank you,

Paul
Copy linkTweet thisAlerts:
@Ay__351_eFeb 09.2012 — What is 2x? 2px?

I use alert message box, If there is an error in my code, I see.

You can delete alert(...);

#nav li a:hover {

color: #c00;

background-color: #fff;

[COLOR="Red"]}[/COLOR]
×

Success!

Help @shark1956 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...