frame forcing solved; other question: javascript between frames
is there a way i can write a variable on one frame to
DOCUMENT.WRITE
on the other?
I wanna be able to put
var title = "whatever"
on every page(where whatever is the title for that page)
and on the other frame(with the navigation bar):
document.write(""+title+"<\/h3>
1. Can i just use the above code as it is, or do i have to use some extra coding to call the variable thats defined in another frame?
2. is it even possible?
3. If i can use the above code is it correct(i mean if there are any errors in it)
sorry for the constant questions with frames.
i've never used them becuase i never found them to be of any use(until now of course), and i need to change my site layout(it was kinda disorganized before since i just threw all my coding onto my editor without giving order(i was excited to bring my site online). help appreciated
thanks.
hehe
Mark Hensler posted this at 04:09 — 11th November 2000.
He has: 4,048 posts
Joined: Aug 2000
Yes... you can change the . Just how do you want to do it?
Server side? this is easy. you just have to change every link on every page to do it. Here's the psuedo-logic.
every link will go to a 'template' .asp file. the .asp file will print HTML to the browser containing your frame info, with the requested page in the proper frame. At the same time, we insert the correct for the requested page.
example
<%
'index.asp
' What page was requested?
Page = Request.QueryString("page")
'What's the <title> for this page?
Select Case Page
Case "home.html":
Title = "This is my home page"
Case "links.html":
Title = "These are some of the best links around!"
Case Else:
Title = "My.Com"
End Select
'Print the template frame page
%>
<html>
<head>
<title><strong><%=Title%></strong></title>
</head>
<FRAMESET ROWS="10%,*" border=0>
<FRAME NAME="left" SRC="nav.html">
<FRAME NAME="body" SRC="<strong><%=Page%></strong>">
</FRAMESET>
</html>
All your links would have to be converted to look like this:
I haven't tested this code, but the thoery is sound. I use similar logic on my site (AtomicPixels.Com), which is written in PHP.
This is the "Quick 'N Dirty" way to do this. If your into databases, that would be the better way to go.
Good Luck,
Mark Hensler
If there is no answer on Google, then there is no question.
Mark Hensler posted this at 04:17 — 11th November 2000.
He has: 4,048 posts
Joined: Aug 2000
forgot about client side...
I don't know how this would be done client side. I've never tried. Vincent would probably know.
*maybe* (this is a highly uneducated guess) you could give the tags an id. Then address them like this:
parent.framename.document.all.titleID.innerHTML = "my new title"
Mark Hensler
If there is no answer on Google, then there is no question.
ianrules posted this at 17:22 — 11th November 2000.
They have: 74 posts
Joined: Sep 2000
sorry i guess i didn't phrase my question correctly
on the content page
<script>
// i wanna set the variable title
var title = "Ian\'s page"
</script>
and on the nav-bar page:
<script>
document.write(title)
</script>
can javascript work across 2 frames like above?
or do i have to edit the code to let the browser know that the variable title is defined in another window.
but i dont wanna use the TITLE tag as the variable.
hehe
Mark Hensler posted this at 18:07 — 11th November 2000.
He has: 4,048 posts
Joined: Aug 2000
Oooohh... I didn't the part about the nav bar before, sorry.
Well, again, all I can think of is that you could give some tags (h3 or whatever) id. Then address them like this:
parent.framename.document.all.titleID.innerHTML = "my new title"
You'd put this on the content page, and point it to the tags in the nav frame that have the id.
I don't know if that will work or not, never tried.
Mark Hensler
If there is no answer on Google, then there is no question.
Vincent Puglia posted this at 19:56 — 11th November 2000.
They have: 634 posts
Joined: Dec 1999
Hi Ian,
First things first. If you are attempting to change a page's (or frame's) title, it will only work with IE. Netscape will not allow you to change the title of an already loaded page/frame. So...although I haven't tried it with frames, I believe it also will not work because the HTML meta tag is loaded, interpreted, and executed before any javascript.
Secondly, the code Max gave you (in fact any code with the keyword 'all' in the DOM -- document object model) is IE-specific (and nowadays NN ver6).
Finally, if you want to try with document.write, the syntax would be:
<script language='javascript'>
" + myTitle + "<\/h3>
//-->
</script>
But, as I said Netscape will probably balk. To make it completely crossbrowser, you would probably have to create the page dynamically, and then load it into the frame you want (probably more work than worth).
If you want to see a tutorial on the title property, see the script/tutorial by that name at my site.
Vinny
BTW Max: You're doing a good job
Where the world once stood
the blades of grass cut me still
Mark Hensler posted this at 23:02 — 11th November 2000.
He has: 4,048 posts
Joined: Aug 2000
Vincent-
Thanks, I felt as though I was stumbling aroung in the dark, lol.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.