Question:
Anything better than HTML Frames?
pablot585
2009-03-09 19:30:15 UTC
I posted earlier asking about how to fix my frame code in HTML. Someone responded saying that frames are not the best way to build a website.
So what is the best way? I would strongly prefer it to be in HTML or CSS, but I will learn PHP if you provide an extremely easy
Beginner tutorial. By the way, can HTML-Kit code PHP?

Thanks a lot!!
Five answers:
Nick C
2009-03-09 19:48:27 UTC
If you need to load content in different sections, use Ajax and divs instead. You can supply the content in hardcoded XML, HTML, and even plain text. However, if you need a more dynamic approach, use PHP or ColdFusion to deliver the content. With Ajax, you can then load the content and print into the divs.



Ajax is the preferred method of content delivery simply because it is easier to style and apply into existing HTML. It is also easier to modify and expand to other content sources. Nonetheless, frames are also an excellent solution in certain cases.



To give a head start into your Ajax, I pasted what I usually use for Ajax objects.



//To create the Ajax object and print to screen



function getContent() {

var url = "yourfile.yourext";

var ajax = new Ajax();

var hand = function(feed) {

//handler function, where feed is the returned info

//the info can come as text or as a XML obejct (DOM)

document.write(feed);

}

//the txt specifies the content type

//use xml if the return type is a XML obejct (DOM)

ajax.doGet(url, hand, 'txt');

}



//Ajax Class



function Ajax() {

this.req = null;

this.url = null;

this.status = null;

this.statusText = '';

this.method = 'GET';

this.async = true;

this.dataPayload = null;

this.readyState = null;

this.responseText = null;

this.responseXML = null;

this.handleResp = null;

this.responseFormat = 'text';

this.mimeType = null;

this.headers = [];





this.init = function() {

var i = 0;

var reqTry = [

function() { return new XMLHttpRequest(); },

function() { return new ActiveXObject('Msxml2.XMLHTTP') },

function() { return new ActiveXObject('Microsoft.XMLHTTP' )} ];



while (!this.req && (i < reqTry.length)) {

try {

this.req = reqTry[i++]();

}

catch(e) {}

}

return true;

};

this.doGet = function(url, hand, format) {

this.url = url;

this.handleResp = hand;

this.responseFormat = format || 'text';

this.doReq();

};

this.doPost = function(url, dataPayload, hand, format) {

this.url = url;

this.dataPayload = dataPayload;

this.handleResp = hand;

this.responseFormat = format || 'text';

this.method = 'POST';

this.doReq();

};

this.doReq = function() {

var self = null;

var req = null;

var headArr = [];



if (!this.init()) {

alert('Could not create XMLHttpRequest object.');

return;

}

req = this.req;

req.open(this.method, this.url, this.async);

if (this.method == "POST") {

req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

}

self = this;

req.onreadystatechange = function() {

var resp = null;

self.readyState = req.readyState;

if (req.readyState == 4) {



self.status = req.status;

self.statusText = req.statusText;

self.responseText = req.responseText;

self.responseXML = req.responseXML;



switch(self.responseFormat) {

case 'text':

resp = self.responseText;

break;

case 'xml':

resp = self.responseXML;

break;

case 'object':

resp = req;

break;

}



if (self.status > 199 && self.status < 300) {

if (!self.handleResp) {

alert('No response handler defined ' +

'for this XMLHttpRequest object.');

return;

}

else {

self.handleResp(resp);

}

}



else {

self.handleErr(resp);

}

}

}

req.send(this.dataPayload);

};

this.abort = function() {

if (this.req) {

this.req.onreadystatechange = function() { };

this.req.abort();

this.req = null;

}

};

this.handleErr = function() {

var errorWin;

try {

errorWin = window.open('', 'errorWin');

errorWin.document.body.innerHTML = this.responseText;

}

catch(e) {

alert('An error occurred, but the error message cannot be' +

' displayed because of your browser\'s pop-up blocker.\n' +

'Please allow pop-ups from this Web site.');

}

};

this.setMimeType = function(mimeType) {

this.mimeType = mimeType;

};

this.setResponseFormat = function(responseFormat) {

this.responseFormat = responseFormat;

}

this.setHandlerResp = function(funcRef) {

this.handleResp = funcRef;

};

this.setHandlerErr = function(funcRef) {

this.handleErr = funcRef;

};

this.setHandlerBoth = function(funcRef) {

this.handleResp = funcRef;

this.handleErr = funcRef;

};

this.setRequestHeader = function(headerName, headerValue) {

this.headers.push(headerName + ': ' + headerValue);

};

}
2009-03-10 01:24:23 UTC
There is nothing wrong with frames. Most people don't like them because they don't know how to code them so they work. But, Server Side Includes would allow you to put anything on ALL your pages that may require editing from time to time. Editing just the include file and overwriting the old one will propagate all the corrections to all the pages that have the include code.



You can use PHP include codes or just use the other non-php ones and modify the .htaccess file to set up SSI. Must have a hosting service that allows SSI whether you use PHP includes or not.



Ron
winkelthorp
2009-03-09 19:37:48 UTC
CSS is by far the best way to design your website. It gets rid of address confusion with frames and it is very easy and customizable. I was converted from frames myself. There are tutorials and pre-made templates and layouts all over the web. Just google what you want and I guarantee results!



I'm sorry, but I can't answer the part about PHP and HTML-Kit, but I bet so. Personally, I use Dreamweaver and highly recommend it but you can most likely do PHP with any program. Just do:




echo "Hello world!";

?>

or whatever you want in your page and it will probably work.

PS - PHP is not an alternative to HTML or CSS, it's a server-side programming language. You can display HTML formatted with CSS thorugh PHP, I do, but it's not an alternative.



Hope that helps!
Nisovin
2009-03-09 19:37:42 UTC
If you only want to be able to include a sidebar into every page of your website, it is simple in PHP. Obviously, your web host needs to support PHP. If it does, you can do the following:



1. Cut the sidebar HTML out of your page and put it in a separate page, name this page "sidebar.html" or "sidebar.php" or whatever.

2. In your page code, where the sidebar should be, put the following:



3. Make sure your pages are saved as .php files instead of .html files.

4. Upload to server.



If you do it right, you will see your sidebar HTML integrated seamlessly into your page HTML.
?
2016-10-30 15:58:35 UTC
Frames are infrequently utilized in cyber web web content anymore via fact there are multiple problems with them. the popular strategies of doing cyber web web content layouts recently is to apply "div layouts" which makes use of div sections controlled by utilising kinds in a CSS report. the difficulty with div layouts is they may well be a splash problematical to learn. on your case i'd advise utilising tables for layouts. they supply you a great number of flexibleness, are undemanding to learn and are lots extra useful then frames.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...