...

View Full Version : script not working in firebird



shlagish
03-15-2004, 02:50 AM
This script is working fine in IE, but not in firebird, what's the problem?
Here is the complete page:



<html>
<head>
<title>edit</title>
<style type="text/css">
<!--

body { background-color: #f1f1f1; }
p { font-family: Tempus Sans ITC, verdana, helvetica, arial; }

-->
</style>
<script type="text/javascript">
<!--

function change()
{
parent.show.location.reload()
parent.show.document.write(myForm.code.value);
return false;
}

function full()
{
w_height=screen.availHeight;
w_width=screen.availWidth;
Test=window.open('','','height=' + w_height + ',width=' + w_width + ',left=0,top=0,resizable=1');
Test.document.write(myForm.code.value);
return false;
}

-->
</script>
</head>
<body>

<p>
By pressing the '<b>Change code</b>' button at the bottom of this page, the code you entered in the text area will appear in the frame to the right. Or you can press the '<b>Make fullscreen</b>' button to see the result in a full size, seperate window.

</p>
<form name="myForm">
<textarea style="width:100%" rows="26" cols="42" name="code">
</textarea>
<input type="button" value="Change code" onClick="change()" />
<input type="button" value="Make fullscreen" onClick="full()" />
</form>

</body>
</html>


I just made this so I could create my web pages and test them directly in the other frame (kind of like the try it yourself windows at w3schools ex (http://www.w3schools.com/html/tryit.asp?filename=tryhtml_basic))
So yeah, I'm just trying to figure out why firebird wont take it (basically because I want to create my pages for firebird and then hack them so they work in IE instead of the contrary)

squirellplaying
03-15-2004, 03:07 AM
Start by click tools then javascript console. That should give you a hint as to where the problem is.

shlagish
03-15-2004, 03:11 AM
Thanks a lot, but I really can't make anything of what it says. for example, what does this mean:

Error: uncaught exception: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getIntPref]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: chrome://cookie/content/cookieTasksOverlay.xul :: CookieTasksStartup :: line 84" data: no]

glenngv
03-15-2004, 03:29 AM
You're not referencing the form and frame properly.

parent.frames['show'].document.write(document.myForm.code.value);
...
Test.document.write(document.myForm.code.value);

squirellplaying
03-15-2004, 03:30 AM
That's wierd. Ussually I get good info from there, but that makes no sence to me at least.

shlagish
03-15-2004, 03:32 AM
Works great! Thanks

shlagish
03-15-2004, 03:57 AM
Another problem though..
When I click the "change code" button and it executes the change() function, firebird wont reload() the page... why?

shlagish
03-16-2004, 11:45 PM
Does anybody know why?
here is the new and improved code


<html>
<head>
<title>edit</title>
<style type="text/css">
<!--

body { background-color: #f1f1f1; }
p { font-family: Tempus Sans ITC, verdana, helvetica, arial; }

-->
</style>
<script type="text/javascript">
<!--

function change()
{
parent.frames['show'].document.location.reload();
parent.frames['show'].document.write(document.myForm.code.value);
return false;
}

function full()
{
w_height=screen.availHeight;
w_width=screen.availWidth;
Test=window.open('','','height=' + w_height + ',width=' + w_width + ',left=0,top=0,resizable=1');
Test.document.write(document.myForm.code.value);
return false;
}

-->
</script>
</head>
<body>

<p>
By pressing the 'Change code' button at the bottom of this page, the code you entered in the text area will appear in the frame to the right. Or you can press the 'Make fullscreen' button to see the result in a full size, seperate window.
</p>
<form name="myForm">
<textarea style="width:100%" rows="26" cols="42" name="code">
</textarea>
<input type="button" value="Change code" onClick="change()" />
<input type="button" value="Make fullscreen" onClick="full()" />
</form>

</body>
</html>

Anyone see anything wrong in here?

glenngv
03-17-2004, 02:58 AM
location is not a property of document but the window.

parent.frames['show'].location.reload();

shlagish
03-17-2004, 03:02 AM
Darn it, thank you.

Do you mind checking out this thread (http://www.codingforums.com/showthread.php?threadid=34805), I can't seem to get any answers..:o
Thanks again for that location thing :)

shlagish
03-17-2004, 03:27 AM
oh, and after testing, the script still doesn't work...

glenngv
03-17-2004, 03:39 AM
But why do you reload the page in the first place? Why not just write out the new page in that frame instead?

shlagish
03-17-2004, 03:43 AM
Your right, I guess I'm sticking to an old method even if it don't work...
I wouldn't know how to do though. would it be with the open() function?

And just out of curiosity, why didn't the reload() work?

glenngv
03-17-2004, 04:17 AM
document.write is enough. It already calls document.open internally.

function change()
{
parent.frames['show'].document.write(document.myForm.code.value);
return false;
}

I think the reload works. It's just that you don't see it because the page is immediately replaced by the new page.

shlagish
03-17-2004, 04:22 AM
The reason why I want it to reload is because I want the page to become blank again before it writes the code. If I only use document.write() , say I make it write "hello", if I do it again but change "hello" to "ouch", the page will show

Hello

ouch

I want it to show only ouch, that's why I want the page to reload (become blank) and then write.
Am I making any sence?

glenngv
03-17-2004, 04:53 AM
Try closing the document.

function change()
{
parent.frames['show'].document.write(document.myForm.code.value);
parent.frames['show'].document.close();
return false;
}

shlagish
03-17-2004, 04:56 AM
It doesn't even show at all.
and I don't see why it should if the page is closed...

glenngv
03-17-2004, 05:50 AM
Any error message?

I think it should because document.write automatically opens the document for writing and discards the previous content. But now try calling document.open explicitly and see what happens.

function change()
{
parent.frames['show'].document.open();
parent.frames['show'].document.write(document.myForm.code.value);
parent.frames['show'].document.close();
return false;
}

BTW, is your site online?

shlagish
03-17-2004, 11:02 PM
Yay, it works. No my site isn't online.
But there is something I don't understand. Why can I see a document that has been closed?

glenngv
03-18-2004, 03:35 AM
It's the document.close() that forces the string in document.write to be displayed.

http://www.devguru.com/Technologies/ecmascript/quickref/doc_close.html

shlagish
03-18-2004, 03:49 AM
That's a very short explanation they have there. I'm not sure I understand, but oh well. I also noticed this:
newWindow.document.writeln("message1)
Why is there a quotation mark in there?
Wouldn't newWindow.document.writeln(message1); work?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum