I'm making a HTML page that uses a seperate HTML page to display a menu in an iframe. The emu itself is written into the second frame using Javascript, so that it can identify the title of the parent frame and use a different background colour for the relevant navigation tab; this is to give the page a shinier look overall. as I am making this website for a business. Here's some of my code, with most of the fluff taken out :)
Font HTML page:
<html lang=en> <head> <title>Home</title> <style media="screen" type="text/css"> @import url(style.css); </style> </head> <body> <IFRAME SRC="navmenu.html" WIDTH=100% HEIGHT=195 ></IFRAME>
...As you can see, this pretty much just displays the iframe containing the navigation menu right off the bat. In the navmenu...
<head> <!--Head stuff--> </head> <body> <TABLE WIDTH=100% ALIGN=LEFT HEIGHT=100> <!--table Stuff--> <SCRIPT SRC="navMenu.js" TYPE="text/javascript"></SCRIPT> </Table></Body></etc...>
...This HTML file is just to tweak how the menu displays itself using lots of table stuff. The actual menu is written into this file by way of a javascript file, navmenu.js. I have decided on this kind of modular implementation so people will (hopefully) be able to maintain the website without much knowledge of HTML after I leave. Anyways, here's the all-important .js file:
var loc = parent.document.title; //I tried this first
var loc = parent.getTitle(); //I tried this next
if (loc == "Home") {
//display a highlighted tab for this menu choice, showing the user that this is the page they're on}
else {
//display a regular tab for this menu choice;}
if (loc == "News") {
//display a highlighted tab for this menu choice, showing the user that this is the page they're on}
else {
//display a regular tab for this menu choice;}
if (loc == "Jobs") {
//display a highlighted tab for this menu choice, showing the user that this is the page they're on}
else {
//display a regular tab for this menu choice;}
...So, yeah, first I tried just accessing the parent's title directly, and it came up with a Javascript error;
Unsafe JavaScript attempt to access frame with URL <file> from frame with URL <file> Domains, protocols and ports must match.
...Which I thought was fair enough, after all, we don't want random javascript pop-ups leeching data from main pages. So, then I tried specifically writing a method in the parent (the home page) to return a string containing the title of the document, but got the same error. So now I'm stumped; is there any way to pass data from one HTML file to another in this manner, or am I beating a dead horse?
Please and thank you! ^_^
~Fae


Sign In
Create Account


Back to top









