473,396 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

document.write won't work just after an href link in a frame

Hi,

I've got a little Quizzer program that asks a question in the upper
frame of a frameset and then lists the answer in the lower frame.
Answers can be plain text, straight html, a sound, or a LINK. I have a
function that builds the answer frame using document.write(among other
things). This code works fine until you encounter a link. It dutifully
displays the link in the lower frame but the very next question builds
the newContent perfectly but does NOT write it to the frame even
though it appears to execute it. Anybody know why?
JS

if (answerType == "link")
{
parent.frames[1].location = URL;
} else {

// pitiful attempt to clear linked page
parent.frames[1].location.href = "QuizzerAnswer.htm";

var newContent = '<html><head><title>Quizzer Answer</title>'
newContent += '</head>';
newContent += '<body>';

if (answerType == "text" || answerType == "html") {
newContent += answerValue;
}

if (answerType == "sound") {
newContent += '<embed src="' + answerValue;
newContent += '" width="170" height="25" autostart="true">'
}

newContent += '</body>';
newContent += '</html>';

parent.frames[1].document.write(newContent);
parent.frames[1].document.close();
}
Jul 23 '05 #1
5 1836


imaband wrote:
I've got a little Quizzer program that asks a question in the upper
frame of a frameset and then lists the answer in the lower frame.
Answers can be plain text, straight html, a sound, or a LINK. I have a
function that builds the answer frame using document.write(among other
things). This code works fine until you encounter a link. It dutifully
displays the link in the lower frame but the very next question builds
the newContent perfectly but does NOT write it to the frame even
though it appears to execute it. Anybody know why?


Your browser's JavaScript console might know and tell you what is wrong.
Anyway, try
parent.frames[1].document.open();
parent.frames[1].document.write(newContent);
parent.frames[1].document.close();
If that doesn't help then tell us which browser you are using, whether
you get any errors in the JavaScript console.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2

Thanks Martin,

I'm using IE6 and enabled script debugging but didn't even get an error
message. I added the open() but that didn't help either. For some reason
it thinks it wrote the string but the window doesn't update. I'm
researching the location object to see if perhaps something might
"reset" the frame to whatever state is required to make this work.

Thanks for your prompt reply.

JS

Software Architect
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
Martin,

The debugger finaly started to work and I got an "Access is Denied"
message right on the document.open() statement.

I'm using ActiveX controls to get the data I need from a CSV file. But
the page in question doesn't reference the TDC directly - only the upper
Question frame does. I'm loading CNN and Google as my LINK. Maybe they
affect the security of sibling frames somehow. I'll try and lower my
security preferences temporarily to see if it solves the problem.

JS

Software Architect
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4


CodeHopper wrote:

The debugger finaly started to work and I got an "Access is Denied"
message right on the document.open() statement.

I'm using ActiveX controls to get the data I need from a CSV file. But
the page in question doesn't reference the TDC directly - only the upper
Question frame does. I'm loading CNN and Google as my LINK.


That is the problem, once you have loaded a page from an origin
different than the one the page with your script is loaded from you are
no longer able to access the document due to the same origin policy.
Try
parent.frames[1].location.href = 'about:blank';
parent.frames[1].document.open();
parent.frames[1].document.write(...);
parent.frames[1].document.close();

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #5
Martin (all),

Nope! Doesn't fix it. Oh well. I guess I'll just open a new window until
I can figure this one out.

I truly appreciate your help though.

Ahhhhh Technology! Isn't it WONDERFUL.

CodeHopper.

Software Architect
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Konrad Mathieu | last post by:
Does this work in most browsers, namely MSIE? document.links.href or does it have to be document.links.href ?
3
by: Catherine Lynn Smith | last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on one layer to modify the content on another but I seem to keep running into errors. Basically I create a layer in the middle...
5
by: John Taylor-Johnston | last post by:
This will give me the source of the current page. <a herf="javascript:document.location = 'view-source:'+document.location">testpage.htm</a> I want to display the source of another page, using...
2
by: PhoneLover | last post by:
Hi, I have a page with this frameset: <frameset cols="185,800*" frameborder="YES" border="2" framespacing="2" rows="*" bordercolor="#FF0000"> <frame name="leftFrame" noresize...
7
by: Remi Bastide | last post by:
I'm trying to open a blank window and write a message in it. The following page works as expected in IE, but in Firefox the message is not written: <HTML> <HEAD> <TITLE>Document.write...
5
by: terence.parker | last post by:
I have a PHP application which I wrote last year - and the JavaScript worked fine then. For some reason, now it doesn't - neither on IE nor Firefox. Has something changed? When I click on my...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
6
by: mistral | last post by:
what is correct way open a PDF document in new window use hyperlink? I want show images thumbnails linked with PDF files, when click on thumbnail, PDF will be opened in new window. Some of PDF...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.