Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 18th, 2004, 04:39 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default PNG Transparency in IE

I have a script that I downloaded that corrects PNG transparency in Internet Explorer 6.

Well I'm dabbling in a bit of cross window scripting and I am having some trouble calling on a function..

Here's an XML layout of how my page is structured

<window>
    <script>
        correctPNG();
    </script>
    <iframe>
        <script>
            create popup...
        </script>
        <popup>
            <frameset>
                <frame1 />
                <frame2 />
                <frame3>
                    PNG images
                </frame3>
            </frameset>
        </popup>
    </iframe>
</window>

I'm trying to call on the function in the top most window, correctPNG, from the thrid frame inside of the popup window...

I've tried the following:

<body onload='top.opener.top.correctPNG();'>

AND

All of the content in the pop-up window is written dynamically using Javascript, I also tried adding JavaScript that way:

msg_parts.document.write('<script language=\'javascript\' type=\'text/javascript\'>\n');
msg_parts.document.write('window.attachEvent(\'onl oad\', top.opener.top.correctPNG)\n');
msg_parts.document.write('</');
msg_parts.document.write('script>\n');

This was output from PHP, which is why the newlines were escaped... \\n

This is how the top most window calls on the function.. which works.. how can I call it in the frameset?? So far neither method has come up with JavaScript errors.. which is strange.

Thanks in advance!
: )
Rich


:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #2 (permalink)  
Old January 19th, 2004, 07:03 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't know the answer but try standard debugging techniques. Give the framesets names and then try:
Code:
alert(top.name);alert(top.opener.name); //etc
in your onload to find out where you are so far.

--

Joe
Reply With Quote
  #3 (permalink)  
Old January 19th, 2004, 10:53 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

If this script is just a utility why not just reference it in the other pages that need it? Seems like that would save you a lot of headache.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #4 (permalink)  
Old January 19th, 2004, 03:44 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Thanks for the suggestions.

I think that the event doesn't fire because the window is opened and written to using JavaScript, so by the time JavaScript starts writing, the onload() handler has already fired long ago.

Quote:
quote:
If this script is just a utility why not just reference it in the other pages that need it? Seems like that would save you a lot of headache.
Well I am thinking an external file would work fabulously for this. I wasn't thinking along those lines originally because my javascript is output with PHP and portions of it change based on a selected color scheme, or change dynamically in some other way.. but I hadn't really noticed this particular script isn't subject to any of that.

I was considering calling on the function this way:

<script language='javascript' type='text/javascript'>
correctPNG();
</script>

Quote:
quote:
alert(top.name);alert(top.opener.name); //etc
Something I guess I left out was I am able to access the opener via top.opener.method and the top frame from the opener via top.method.

After reading your replies I began to suspect my event handler was to blame. So if onload() doesn't work... will I have to cache the images before calling the function as above? I guess I will just have to try it! For the time being though I have a greater bug to crush...

Thanks!
: )
Rich


:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #5 (permalink)  
Old January 19th, 2004, 08:26 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by quesadilla5
Well I am thinking an external file would work fabulously for this. I wasn't thinking along those lines originally because my javascript is output with PHP and portions of it change based on a selected color scheme, or change dynamically in some other way.. but I hadn't really noticed this particular script isn't subject to any of that.
Use an external PHP file that generates just the javascript you need:

<?php // my_javascript.php

if (isset($_GET['some_var']))
{
   echo "some javascript code";
}
else
{
   echo "some other javascript code";
}

?>


Then, in your HTML documents:

<html>
<head>

<script language="JavaScript"
        src="my_javascript.php?some_var=some_value"
        type="text/javascript">
</script>
</head>
<body>
....
</body>
</html>


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bitmap Transparency tahcue C++ Programming 0 December 19th, 2007 07:45 PM
creating html from png Alper HTML Code Clinic 2 November 2nd, 2007 10:02 PM
Transparency and repainting Volt9000 C# 0 December 18th, 2004 01:00 AM
Transparency Problem blah VB.NET 2002/2003 Basics 0 October 30th, 2003 02:40 AM
displaying png in web form dotnettergirl Pro VB.NET 2002/2003 0 July 16th, 2003 10:15 PM



All times are GMT -4. The time now is 12:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.