Sure, uhm.. say your java script belongs in the <body> tag so that it's
run when the page loads. is the page you want
to include in your site with the javascript.
the file() function would probably work better than fopen, so I'll use



$javascript = "onLoad='something blah blah"; // This is your javascript
to insert.

$page = file ("";); // This is the
page you wish to display with your javascript.

foreach ($page as $line) {  // Go through the file line by line.

    if (stristr($line, "<body")) {  // if the line contains the <body

            $pos = strpos(strtolower($line), "<body"); // Get the
position within the line 
            $first_half = substr($line, 0, $pos+6); // split the line
into two parts right after <body
            $second_half = substr($line,$pos, strlen($line)-($pos+6))
            echo $first_half . $javascript . " " . $second_half ; //
echo the line with your javascript inserted.
    } else { // if the line doesn't contain "<body" just echo it. 
            echo $line;


That's the idea anyway. I didn't test this, but I'm guessing it's pretty
close. I know stristr() may not be the best routine to use, and there's
a couple places I'm seeing already where you could optimize things, but
you get the idea. 

Anyone have a better way to do that? 


On Sat, 2003-02-22 at 11:54, Matt Palermo wrote:

> I don’t really know how to go about doing that.  Could you go into a
> more in depth explanation please? Thank you.
> Matt
> -----Original Message-----
> From: Micah Stevens [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, February 22, 2003 2:07 PM
> To: Matt
> Subject: Re: [PHP-DB] disable right-click in all frames.
> Sure there is, 
> just fopen the remote page, get it, and then parse it until you know
> you're in the <body> tag, where you can insert your Javascript. Then
> just output the rest. 
> -Micah
> On Sat, 2003-02-22 at 05:22, Matt wrote: 
> hey everyone.  i have a php script that opens up a new window with multiple
> frames.  i am using javascript to disable the right-click mouse button on
> the frames.  the problem is that on of the frames uses and external source,
> which i can't change or modifiy at all.  is there a way for me to disable
> the right-click mouse button in that frame?  is there just some way to
> disable the right-click in all frames (no matter what the source) on a given
> page?  please let me know if you have any ideas.  thanks.
> matt

Reply via email to