Burt H. Shulman

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromBurt H. Shulman
ToMe
Subjectjavascript and context menus
Date2 February 2006 07:02
Dear Mr.  Wilton-Jones,

I am working on a project and could use some expert help. I know very little 
about Javascript, DOM, CSS, etc. I'm a mechanical engineer.

I would like to be able to do the following things on my win98 / IE6 computer.
1). right click on any webpage image and open it in a fullscreen explorer 
window, using a context menu entry. So far I can open any image in a new 
explorer window, but the window has all the toolbars active.
<SCRIPT>
open(external.menuArguments.event.srcElement.href)
</SCRIPT>
I can't figure out how to write the fullscreen attribute to work with this.

2). I want to be able to zoom in and out on the image in the new window with a 
context menu entry. I already can do this using the Web Accessories 
Zoomin/Zoomout, which i downloaded.

3). I want to modulate the brightness of the image with a mouseover (on the image).
I am using the opacity method to lighten the image, but a true brightness 
control (RGB) would be better. Is this correct? Also I can get the code below to 
work only
a). when src="a stored image file"
and
b). when I double click on the .htm icon of the page which contains the code.

When I try to incorporate  a variable based statement 
src="(external.menuArguments.event.srcElement.src)"  so the code will operate on 
the current right clicked image, the code doesn't work.
Also, I read that when script is called by using the context menu, no page is 
opened, it just executes the script. How can the html portion of the code 
(below) run, if no page is opened? Is that a valid question?


<HTML>
<script>
var aaa=(menuArguments.event.srcElement.src);
function makevisible(cur,which)
strength=(which==0)? 1 : 0.6
cur.filters.alpha.opacity=strength*100
</script>

<p><img style="filter:alpha(opacity=60);
onMouseover="makevisible(this,0)" onMouseout="makevisible(this,1)"

src="C:\WINDOWS\Desktop\Cap1.jpg"   
HERE IS WHERE I PUT     src="aaa"     INSTEAD OF THE ABOVE

border="0" target="_top" alt=" " onmouseover="window.status=' '; return true;" 
/><br />
</HTML>

So, can you write the code so that it will perform a (RGB)brightening 
function(by a preset amount on mouseover and can you add it into the Open in a 
new window script above?

Thank you very much for your time.
Sincerely,
Burt H. Shulman
FromMe
ToBurt H. Shulman
SubjectRe: javascript and context menus
Date6 February 2006 16:16
Burt,

> 1). right click on any webpage image and open it in a fullscreen explorer
> window, using a context menu entry. So far I can open any image in a new
> explorer window, but the window has all the toolbars active.

in IE 6 (before XP SP 2, where this was disabled) supposedly, the command
is:
window.open('url','_blank','fullscreen=yes');

You can also specify other options:
http://www.howtocreate.co.uk/tutorials/jsexamples/popwin.html

> 2). I want to be able to zoom in and out on the image in the new window
> with a context menu entry. I already can do this using the Web Accessories
> Zoomin/Zoomout, which i downloaded.

in IE, you can manipulate the zoom style, but it is very buggy. if you have
something that works, I suggest you stick with it. I have a sample script
on:
http://www.howtocreate.co.uk/tutorials/jsexamples/contextmenu/

> 3). I want to modulate the brightness of the image with a mouseover (on
> the image).
> I am using the opacity method to lighten the image, but a true brightness
> control (RGB) would be better. Is this correct? Also I can get the code
> below to work only

I am sure IE's filters will have something for this, but I do not play with
them very much (since I do not use IE, and I dislike browser-specific
hacks):
http://msdn.microsoft.com/workshop/author/filter/reference/reference.asp

> a). when src="a stored image file"
> and
> b). when I double click on the .htm icon of the page which contains the
> code.

sounds like a security restriction. IE's security restrictions are just
weird, and this is one I do not know. But overall it seems to be different
when pages are stored locally, so it seems to be applying some form of cross
domain restriction. Exactly why that triggers I do not know.

> Also, I read that when script is called by using the context menu, no page
> is opened, it just executes the script. How can the html portion of the code
> (below) run, if no page is opened? Is that a valid question?

it runs in an invisible page, you just never see it. It opens a virtual page
in memory, runs any scripts, and as soon as it is finished, it "closes" it.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromBurt H. Shulman
ToMe
Subjectthank you for your help
Date7 February 2006 20:35
Dear Mr. Jones,
Thank you again for your help. May I ask another question?
You mentioned that a security issue may be keeping IE6 from executing some 
script called by a context menu entry. I have script which is being run from the 
context menu, but it seems to be a script "problem". The problem is that I dont 
know how to write a script that will apply a new opacity to an image that has 
been right clicked. I have a script which i copied from MSDN the image  alpha 
filter  example. which I tried to modify so that it would operate on the right 
clicked image. I can get the correct file path for the image, as returned by the 
alert statement, but I cant get the img src statement correct, in  order to 
operate on the image. I used the external.menuarguments property.
can you fix this script, so that it will change the opacity of the image whose 
path and file name is contained in the variable aaa ? I dont need the text and 
color parts of the scrip, just the opacity change.
Thank you for your time.
Burt

<script>
var aaa=(external.menuArguments.event.srcElement.href)
alert(aaa)
</script>
<SPAN id=imgObj style="PADDING-RIGHT: 10px; PADDING-LEFT: 13px; FILTER: 
progid:DXImageTransform.Microsoft.Alpha( style=0,opacity=25); FONT: bold 9pt/1.3 
verdana; WIDTH: 305px; COLOR: darkred; HEIGHT: 150px; BACKGROUND-COLOR: 
skyblue"><IMG id=oImg style="MARGIN: 8px"

Here is where the problem is:

src="(external.menuArguments.event.srcElement.href)"               or  src"aaa" 
doesn't work

align=left>
<DIV id=imgObjText><BR>The image, dark red text, and sky blue background make up 
the content of the filtered SPAN.</DIV></SPAN>
FromMe
ToBurt H. Shulman
SubjectRe: thank you for your help
Date9 February 2006 16:09
Burt,

> The problem is that I dont know how to write a script that will apply a
> new opacity to an image that has been right clicked.

I _think_ this is something like:

<script type="text/javascript">
external.menuArguments.event.srcElement.filters.alpha.opacity = 50;
</script>

You may find that fails if the image does not already have a filter though.

> <SPAN id=imgObj style="PADDING-RIGHT: 10px; PADDING-LEFT: 13px; FILTER:
> progid:DXImageTransform.Microsoft.Alpha( style=0,opacity=25); FONT: bold
> 9pt/1.3 verdana; WIDTH: 305px; COLOR: darkred; HEIGHT: 150px;
> BACKGROUND-COLOR: skyblue">

You are applying the filter to a span? not the image itself? This should not
be needed. Just apply it directly to the image (make sure it has either
height or width defined).

> src="(external.menuArguments.event.srcElement.href)"

I really do not understand what you are trying to do here. Firstly, there is
no need to reference the image by its src (not href - that is for links),
since you already have a reference to the image;
external.menuArguments.event.srcElement

Secondly, why are you putting script into the HTML, and what exactly do you
intend to do with this HTML?

Sorry, but your script does not seem to make much sense, so I may not be
giving you the best answer.


Tarquin
FromBurt H. Shulman
ToMe
SubjectRe: thank you for your help
Date9 February 2006 17:49
Attachmentscreenshot of an IE error message saying that external.menuArguments.event.srcElement.filters.alpha is not an object
Dear Mr. Jones,
Thank  you for writing back. What I am trying to do is write a script, which 
will be called by a context menu entry. The script will lighten the image that 
was right clicked on. I already have context menu entries that will open the 
right clicked image in a new window, zoom in and zoom out. I can't seem to make 
the "opacity change" script work.  All scripts that change the opacity of a 
"script specified image" on my hard drive, work fine if they are run by double 
clicking on the "explorer .htm file" that the script is stored in, but not when 
I try to generalise the script by using  "menuArguments".
 The script you gave me to try
<script type="text/javascript">
external.menuArguments.event.srcElement.filters.alpha.opacity = 50;
</script>
gives this error message when called by the context menu system after clicking 
on the arbitray webpage image. 
What might be the problem? Can I call you?
Sincerely,
Burt
FromMe
ToBurt H. Shulman
SubjectRe: applying opacity to images using the context menu
Date10 February 2006 09:38
Burt,

>  The script you gave me to try
> gives this error message when called by the context menu system after
> clicking on the arbitray webpage image. 

bah. IE as unhelpful as ever. OK, so try this maybe:
<script type="text/javascript">
alert('1 '+external);
alert('2 '+external.menuArguments);
alert('3 '+external.menuArguments.event);
alert('4 '+external.menuArguments.event.srcElement);
alert('5 '+external.menuArguments.event.srcElement.filters);
alert('6 '+external.menuArguments.event.srcElement.filters.alpha);
</script>

Tell me which one comes up undefined or null. (the ones after it will trow
an error). From that I should be able to see if it is a general problem
that cannot be avoided, or if the opacity just needs to be specified
differently.


Tarquin
FromBurt H. Shulman
ToMe
SubjectYou are great!
Date10 February 2006 17:57
AyttachmentsScreenshots showing that alert number 6 is undefined
Dear Mr. Jones,
First I must compliment you. I have posed this script "problem" to about 10 
people who have posted on various development websites and although they appear 
to have a grasp of Javascript, could not help me. This includes 2 local college 
professors....so...Thank you, for knowing what you are doing.
Burt

OK

here are the results:
Now how to return or define the opacity?
FromMe
ToBurt H. Shulman
SubjectRe: applying opacity to images using the context menu
Date10 February 2006 18:44
Burt

> here are the results:
> Now how to return or define the opacity?

Right, the good news is that this should be easy.
since the only one that returned undefined was the alpha filter, it means
you have referenced everything else correctly, and all you need to do is to
specify the alpha filter.

<script type="text/javascript">
external.menuArguments.event.srcElement.style.filter = 'alpha(opacity=50)';
</script>
FromBurt H. Shulman
ToMe
SubjectRe: applying opacity to images using the context menu
Date10 February 2006 22:17
Hi
Yes that works fine.....great...in fact each time I impliment my 
BRIGHTEN menu entry, it gets progressively brighter....and I can use the 
refresh to get back to the original image.

Actually i get one brightening when i click on the image and another 
dose of brightening when i click off the picture, in the window area.
I think the script can brighten the image and then brighten the window 
as well. Is that the situation?
My context menu filter is set to allow the Brighten context menu entry 
to appear in the context menu when right clicked on all objects, which 
is ok for me.

I have no idea how much time 
you want to spend helping me...but I hope I can consider you a mentor 
and resource.

I also wanted to understand how to get the brightening effect to wait 
until I do a mouseover event and then restore the image to 100% opacity 
  on mouseout.

Burt
FromMe
ToBurt H. Shulman
SubjectRe: applying opacity to images using the context menu
Date20 February 2006 09:19
>> each time I impliment my
>> BRIGHTEN menu entry, it gets progressively brighter
>
> Actually i get one brightening when i click on the image and another dose
> of brightening when i click off the picture, in the window area.
> I think the script can brighten the image and then brighten the window as
> well. Is that the situation?

It will apply the opacity to _any_ element.

> I also wanted to understand how to get the brightening effect to wait
> until I do a mouseover event and then restore the image to 100% opacity
> on mouseout.

This requires you to attach event handlers to the object. Unfortunately, IE
has a scope problem here. If you create event handlers, it will associate
them with the scope of the hidden window, which closes when the script has
finished, thus removing the event handlers again. So in other words, no, I
cannot do that :)
FromBurt H. Shulman
ToMe
SubjectRe: applying opacity to images using the context menu
Date20 February 2006 16:20
Thank you again,
What You gave me, is so useful.
Burt
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.