Network: Don't lose your place in the cyberbook
Web Design
Your support helps us to tell the story
From reproductive rights to climate change to Big Tech, The Independent is on the ground when the story is developing. Whether it's investigating the financials of Elon Musk's pro-Trump PAC or producing our latest documentary, 'The A Word', which shines a light on the American women fighting for reproductive rights, we know how important it is to parse out the facts from the messaging.
At such a critical moment in US history, we need reporters on the ground. Your donation allows us to keep sending journalists to speak to both sides of the story.
The Independent is trusted by Americans across the entire political spectrum. And unlike many other quality news outlets, we choose not to lock Americans out of our reporting and analysis with paywalls. We believe quality journalism should be available to everyone, paid for by those who can afford it.
Your support makes all the difference.IMAGINE YOU'RE reading a book. You finish for the night and place a bookmark on the last page you've read. The next night, you want to resume reading where you left off but your bookmark returns you to the cover of the book and you have to flip through all the pages again to get back to where you were. If you are creating a website using frames, that is how it may appear to your visitors: they want to bookmark a page within the site, but they end up bookmarking the cover.
This is not the only problem with referencing framed Web pages. What if you want to refer a visitor to a specific page within the site from an e-mail or from another website? Sure, you can give them the URL for that page, but if you send them directly to that page without the frames, it's like giving them the book without the other pages or the spine. You could create a different frameset document for each page, but this is problematic and unwieldy.
There is an easier way. No, we can't change the way that frames work, and for some reason the browser manufacturers have ignored these major usability problems. However, we can implement a workaround in our website to help visitors overcome these problems.
For example, on my site, Webbed Environments (http:// www.webbedenvironments.com), I wanted to set up an archive of all of my columns. I get questions daily from readers asking me questions to do with the Web, and it is much easier for me, and usually more informative for the person writing to me, if I can simply refer them to one of my columns.
However, I use an extensive frameset in order to create the user interface for my site. To point them directly to an article and keep them in the associated frameset, I came up with a system whereby once an article is loaded, it checks to see if it is in the Webbed Environments frameset. If it is not, it opens the frameset and places itself into the content frame of that frameset. If the article is already in the frameset, then it does nothing. If you want to see an example of this, you can go directly to my article from a few weeks ago about building a better cross-browser DOM (http://www. webbedenvironments.com/ articles/66.html). Notice that the article briefly flashes up, but is then replaced by the frameset and the article is inside.
Step 1: Set up the content
document file
The first thing to do is add JavaScript to every document that will need to be loaded automatically into the frameset. In the
myPage = self.location;
thisPage = top.location;
if (thisPage == myPage)
{ contentSRC = escape(myPage);
frameURL = `index.html?' + contentSRC;
top.location.href = frameURL; }
This script first determines whether the document is loaded into a frameset or not by comparing the document's URL to the URL of the entire window. If it is in a frameset, the URLs will be different and nothing happens. If the URLs are the same (ie, there is no surrounding frameset), then the script will translate the URL for that page (myPage) into ASCII text, combine that with the URL for the frameset to be used (in this case called index.html) and then reset the location of the window to this new frameURL.
Step 2: Set up the
frameset file
The next step is to set up a frameset (index.html) that will take frameURL and extract from it the URL for the page to be loaded into the content frame. To do this, we will actually have to use JavaScript to locate the contentSRC and write out our framesets. It will look something like this:
contentSRC = (location.search. substring(1)) ? location.search.substring(1) : `defaultContent.html';
contentSRC = unescape(contentSRC);
var writeFrame = `'
writeFrame += `
writeFrame += `
Join our commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies
Comments