PDA

View Full Version : Dynamically Loading Content to Nested Frames


mwproductions
08-20-2004, 10:44 AM
I know, I know, but go with me on this one.

Or don't, actually. It you can think of a better way to do this, I'm all ears.

So here's what I'm trying to do:

On my site, http://www.alifelessordinary.com/, I recently added the option for users to take an RSS feed of my blog. Thing is, the way my site is structured, the blog normally loads inside of a nested frame, but when you visit entries from your aggregator, they don't load inside the frames.

This isn't the worst problem I've ever encountered (and it hasn't yet become the most annoying, though not for lack of trying), but it is one that I'd like to solve.

In doing so, I found the following JavaScript code:

document.write('<frameset cols="50%,*">');
document.write('<frame src="apage.html" name="upperFrame">');
document.write('<frame src="' + (location.search ? location.search.substring(1):'bpage.html') + '" name="lowerFrame">');
document.write('</frameset>');

Which I then modified to work with my nested frame (I was planning on working from the inside out).

The current code for the nested frame is:

<FRAMESET COLS="180,*" FRAMEBORDER="NO" BORDER="10" FRAMESPACING="0">
<FRAMESET ROWS="130,*" FRAMEBORDER="NO" BORDER="0" FRAMESPACING="0">
<FRAME NAME="calFrame" SCROLLING="NO" noresize SRC="allo.blog.cal.htm">
<FRAME NAME="navFrame" SCROLLING="AUTO" noresize SRC="allo.blog.nav.htm">
</FRAMESET>
<FRAME NAME="viewFrame" SCROLLING="AUTO" noresize SRC="allo.blog.view.htm">
</FRAMESET>

So I changed the JavaScript code I found to read:

document.write('<FRAMESET COLS="180,*" FRAMEBORDER="NO" BORDER="10" FRAMESPACING="0">');
document.write('<FRAMESET ROWS="130,*" FRAMEBORDER="NO" BORDER="0" FRAMESPACING="0">');
document.write(' <FRAME NAME="calFrame" SCROLLING="NO" noresize SRC="allo.blog.cal.htm">');
document.write(' <FRAME NAME="navFrame" SCROLLING="AUTO" noresize SRC="allo.blog.nav.htm">');
document.write('</FRAMESET>');
document.write(' <FRAME NAME="viewFrame" SCROLLING="AUTO" noresize SRC="' + (location.search ? location.search.substring(1):'allo.blog.view.htm') + '>');
document.write('</FRAMESET>');

Perhaps it's just because I'm using IE (I read on a page somewhere that this is a Netscape thing), but it wouldn't work properly and I have no idea why. The cal and nav pages loaded properly, but the view page wouldn't load at all. See the results here (http://www.alifelessordinary.com/mt/frametest.htm).

I know the slightest bit of PHP and am working to learn more and this seems like the kind of thing that might be a good project for me (after all, isn't the best way to learn by doing?).

So, bearing in mind that I'll have to sort out how to ensure that the nested frame then loads inside the main frame (as seen on the index page of my site), any ideas?

Much thanks in advance...

senshi
08-26-2004, 12:27 AM
Originally posted by mwproductions
So I changed the JavaScript code I found to read:

document.write('<FRAMESET COLS="180,*" FRAMEBORDER="NO" BORDER="10" FRAMESPACING="0">');
document.write('<FRAMESET ROWS="130,*" FRAMEBORDER="NO" BORDER="0" FRAMESPACING="0">');
document.write(' <FRAME NAME="calFrame" SCROLLING="NO" noresize SRC="allo.blog.cal.htm">');
document.write(' <FRAME NAME="navFrame" SCROLLING="AUTO" noresize SRC="allo.blog.nav.htm">');
document.write('</FRAMESET>');
document.write(' <FRAME NAME="viewFrame" SCROLLING="AUTO" noresize SRC="' + (location.search ? location.search.substring(1):'allo.blog.view.htm') + '>');
document.write('</FRAMESET>');


document.write("<FRAMESET COLS=\"180,*\" FRAMEBORDER=\"NO\" BORDER=\"10\" FRAMESPACING=\"0\">");

and

document.write("<FRAME NAME=\"navFrame\" SCROLLING=\"AUTO\" noresize SRC=\"allo.blog.nav.htm\">");

in other words.... DONT Mix " and ' as this can confuse your Strings, stick with all " ' s" or all ' "s ' and remember that the \ MUST be placed before a \" like so, it then gets treated like a " or a ' and not as a string termination...

AaronCampbell
08-26-2004, 12:03 PM
Actually, in my experiance, it is easier (and cleaner) to use one type of quote for your string, and the other type INSIDE your string. That way, you don't have to worry about the \. Such as:
var var1 = '"This is an example" said me.';

mwproductions
08-26-2004, 12:51 PM
Which is part of what I liked about the way I had it. What confuses me is why everything loads properly except the line of code that reads:

Which is part of what I liked about the way I had it. What confuses me is why everything loads properly except the line of code that reads:

document.write(' <FRAME NAME="viewFrame" SCROLLING="AUTO" noresize SRC="' + (location.search ? location.search.substring(1):'allo.blog.view.htm') + '>')

It won't load the page "allo.blog.view.htm" or anything other page I try to send to it from the test page.

Frame test page. (http://www.alifelessordinary.com/mt/frametest.htm)
Sending a page to the frame test. (http://www.alifelessordinary.com/mt/test.htm)