473,696 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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><t itle>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 1863


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
9252
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
9826
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 of the screen that initially comes up with a gif image of a house: <!-- start "house" layer definition for center of screen --> <DIV id="house" style="position:absolute; left:140px; top:137px; width:510px; height:325px; z-index:2"><img...
5
12585
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 something like this but it doesn't work: <a herf="javascript:document.location = 'view-source:'+'testpage.htm'>testpage.htm</a> ?? Won't work, unless it is saved on a server with http:// in front of it.
2
2148
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 src="SpagnoloLeftFrame.html"> <frame name="mainFrame" src="SpagnoloIntro.html"> in SpagnoloIntro.html I have put this javascript code (in the body):
7
2752
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 bug</TITLE> <Script Language="JavaScript"> function load() { var w = window.open('','','');
5
33879
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 HTML link now (which executes a JS function), the firefox JS console tells me: Error: document.SubjectsForm.submit is not a function Any help would be much appreciated. Thanks!
136
9379
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 code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
6
18219
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 files are in the same web server, other are in a remote location. Any help will be appreciated.
0
8656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8592
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9141
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9005
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7694
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4351
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4605
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2306
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.