...

View Full Version : document.title in same window.



jefgees
01-15-2004, 10:07 AM
Some time ago glenngv helped me with the following scripts:

PageA.html à “copy and paste” or “reproduce” the (document.title) on another page (when this opens in a new window).

PageB.html à e-mailgenerator that puts the “copied document.title” in the subject-line of the e-mail.

Hereby the code:
PageA.html
<script>
function doOpen(url, target){
var w = window.open(url,target);
w.document.title = document.title;
w.focus();
return false;
}-->
</script>
...
<a href="B.html" target="_blank" onclick="return doOpen(this.href, this.target)">TextOrImageThatLinksToB.html</a>



PageB.html (opens in a new window)

<html>
<head>
<title>TITLE TEST (this is ‘+t+’ )</title>
<script>
<!--
function changeMailto(i){
i = escape(i);
t = document.title;
mailtoString = '<a href="mailto:?subject='+i+' – '+t+' ( ) ">Generate E-MailWithThe documentTitleInTheSubjectline</a>';
document.getElementById('test').innerHTML = mailtoString;
}
-->
</script>
</head>
<body>
<form>
<select onchange="changeMailto(this.options[this.selectedIndex].value)">
<option value="apples">apples</option>
<option value="oranges">oranges</option>
<option value="bananas">bananas</option>
</select>
</form>
<br />
<div name="email" id="test" align=”center”></div>
</body>
</html>
I restyled the webpages and am working now with 2 frames (FrameLeft and FrameRight). FrameLeft contains the navigationmenu.
If pageB.html (FrameRight) opens in the same window, glenngv mentioned something about a cookie or the persistent property window.name to retrieve the document.title Can somebody please help me with the script so that that pageB.html opens in the same window as pageA.html (=FrameRight) and copies the document.title of pageA.html in the script of pageB.html, so that the e-mailgenerator is still working?
Thanks.
Jef gees
jefgees@westbrabant.net

Mr J
01-15-2004, 03:06 PM
This may be one way to do it.



In your nav page

<script>
<!--
page_title=""

function temp(t){
page_title=t
}
// -->
</script>

Then in all pages loaded into your right frame

<script>
function save_title(){
parent.leftframe.temp(document.title)
}

function get_title(){
last_title=parent.leftframe.page_title
}
</script>


<BODY onload="get_title()" onunload="save_title()">

See attachment for working example

jefgees
01-18-2004, 03:27 PM
Thanks already Mr J for trying to give me a helping hand.
I tried it … but it didn’t work.
Maybe I didn’t explain it the right way.

I am working with 2 frames (LeftFrame and RightFrame)
The LeftFrame contains the navigationbar.
From this navigationbar I can select page’s that appear in the RightFrame.
Suppose I selected the item “orders” in the navigationbar (Leftframe)
In this case a page appears in the Rightframe.
Here I’m in the RightFrame.
Now I have several options to select..
Suppose I choose for “FRUIT”. When I click this item, a new page (=pageA.html) opens in the RightFrame.
PageA.html
<title>How many </title>
On this page is a link to pageB.html.

PageB.html (If possible should open in the same window=RightFrame)

This page is going to generate an e-mail with in the subject-line the document title of page A + the selected item in pageB.html followed by a question mark.

<html>
<head>
<title>HereShouldComeTheTitleOfPageA_InThisCaseHowmay (=this is ‘+t+’ in the mailtoString)</title>

<script>
<!--
function changeMailto(i){
i = escape(i);
t = document.title;
mailtoString = '<a href="mailto:?subject='+i+' – '+t+' ? ">Generate E-MailWithThe documentTitleInTheSubjectline</a>';
document.getElementById('test').innerHTML = mailtoString;
}
-->
</script>
</head>
<body>
<form>
<select onchange="changeMailto(this.options[this.selectedIndex].value)">
<option value="apples">apples</option>
<option value="oranges">oranges</option>
<option value="bananas">bananas</option>
</select>
</form>
<br />
<div name="email" id="test" align=”center”></div>
</body>
</html>
I hope you can help me. I tried already to put the content of what was supposed to be for the LeftFrame in the pages of the RightFrame. And content that was supposed for the RightFrame in the e-mailgeneratorPage. But I couldn(t get it work. So I hope you or someone else can help me. Thanks a lot.
Jef gees
jefgees@westbrabant.net

Mr J
01-18-2004, 09:32 PM
Lets see if we are a bit nearer with this one

glenngv
01-19-2004, 07:56 AM
There are many ways to pass data from one page to another using javascript. Read this article (http://www.webxpertz.net/faqs/jsfaq/passvars.php).

jefgees
01-21-2004, 02:56 PM
Glenngv and Mr J,

Thank you very much … but it isn’t working. I tried everything, but still no progress.

Am I wrong but I think It has something to do with a template I’m using to generate the “A.html’ pages. (There are about 500 pages where there is a link tot the e-mailgenerator (=pageB). That’s where glennv helped me a lot.

When I change the template and put the script in the head it is over. The link to the emailgenerator (= page B does not work anymore.). So I think it has to do with the template.

Maybe it is easier to go back to the first script and try to close the page (=pageA) when I go to the emailgenerator (pageB). Is this possible?? I mean the moment I click the link on pageA.html (to go to the emailgenerator), page A should close. Is this possible or is it fiction??

Sorry to bother you, but I would appreciate it very much if you could give me a helping hand
Thanks.

Jef gees
jefgees@westbrabant.net

jefgees
01-21-2004, 07:02 PM
Glenngv and Mr J and or someone who can help me,

Sorry, sorry, sorry …
but I got it wrong.
It is not pageA.html that has to close, but page B (= emailgenerator-page).
Is this possible?? I mean the moment I click on the emailgenerator and start the e-mail-application page B should close. Is this possible or is it fiction??

Sorry again but It is not that easy for me.
Jef gees
jefgees@westbrabant.net

Mr J
01-21-2004, 10:48 PM
Post a copy of your frameset and pageA, pageB etc

jefgees
01-22-2004, 12:26 PM
I hope you can do something with it. I skimmed the site but I left the most important part (=emailgenerator), because otherwise the file is becoming too huge. Got a message that the file was too big.

Is it possible to close the emailgenerator-page the moment you go to your email-program?

Looking forward and keeping my fingers crossed for a solution,

Jef Gees
jefgees@westbrabant.net

jefgees
01-22-2004, 01:54 PM
here is another zip.file with the code you mentioned. (i noticed that with the previous version something goes wrong with the template).

glenngv
01-23-2004, 01:40 AM
Is this what you wanted?



function changeMailtoCOLL(i){
i = escape(i);
t = document.title;
mailtoString = '<a href="mailto:?subject='+i+' – '+t+' ( )" onclick="window.close()"><span class="labelr">&nbsp;@&nbsp;</a>';
document.getElementById('test').innerHTML = mailtoString;
}

jefgees
01-26-2004, 12:52 PM
Yes, yes, yes!
Thanks a lot Glenn and Mr J,
You can make this look so simple!
Thanks again.

I noticed in the forum a topic named “Auto-selecting options based on continuous keystrokes”. I’ll try to integrate this with the e-mailgenerator. Let you know if I could make it.
Thanks a lot.

Jef Gees
jef.gees@westbrabant.net



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum