/    Sign up×
Community /Pin to ProfileBookmark

just open.window…

OKay I am using this script to open a new window.

<script language=”JavaScript”>
<!–
function openWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,’width=315,height=415, left=0,top=0,screenX=0,screenY=0′);
}
//–>
</script>

The link is:
<A HREF=”whatever.jpg” onClick=”openWindow(‘whatever.jpg’,’1′); return false”>blablabla</A>

The picture dont all have the same size. Its between 282-435 and 303-449.

Everything works fine, But I would like to have a black background instead of a white one behind the pictures. I would also like to have the picture (not the window) to begin at the top left. A small space is always present on the left and the top of the picture.

TIA

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@FromU2MEDec 29.2005 — You could write this to display in your popup:

[CODE]<script language="JavaScript">
<!--

function openWindow(theURL,winName,features) { //v2.0

var top = "<html><head><title>...</title></head><body background='#000000' style='margin:0px'><img src='";
var bot = "'></body></html>";

var newWin = window.open('', winName, 'width=315, height=415, left=0, top=0, screenX=0, screenY=0');

newWin.document.write(top + theURL + bot);
newWin.document.close();

}
//-->
</script>


[/CODE]
Copy linkTweet thisAlerts:
@baseiberDec 29.2005 — It looks like you are missing a parameter when you are calling your function.
Copy linkTweet thisAlerts:
@pangoauthorDec 29.2005 — Thanks for the quick reply and the script FromU2ME.

The margin work, but not the background color.

Also I saw that I can add a title. What i have to add in my link, so I can have a title for each pictures that I open in this new window. It si possible?

Thanks again
Copy linkTweet thisAlerts:
@FromU2MEDec 29.2005 — Sorry about that - must be tirred or something... :S

The correct tag is [B]<body bgcolor='#000000'>[/B]

To add in your link:

[CODE]<A HREF="whatever.jpg" onClick="openWindow('whatever.jpg','1','',[COLOR=Red]'title_goes_here'[/COLOR]); return false">blablabla</A>[/CODE]
Also, make this change in the JavaScript:

[CODE] function openWindow(theURL,winName,features, [COLOR=Red]theTitle[/COLOR]) { //v2.0

var top = "<html><head><title>" [COLOR=Red]+ theTitle +[/COLOR] "</title></head><body bgcolor='#000000' style='margin:0px'><img src='";[/CODE]
Copy linkTweet thisAlerts:
@pangoauthorDec 29.2005 — FromU2ME,

Well you are really quick...

No harms done about the small mistake, I even make the correction myself, after I reply to you.

I have now a better understanding about the logic of javascript.

Thanks for all the help.
Copy linkTweet thisAlerts:
@pangoauthorDec 30.2005 — A little precision, in some browser like Opera

style='margin: 0px' dont work

Use also:

marginwidth= '0px' marginheight= '0px'

So I have now:

<body bgcolor='#000000' marginwidth= '0px' marginheight= '0px' style='margin: 0px'>
Copy linkTweet thisAlerts:
@FromU2MEDec 30.2005 — Opera uses [B]padding[/B] instead of margin, since they don't see the space around the document as margin but as padding...
Copy linkTweet thisAlerts:
@pangoauthorJan 25.2006 — Well thanks to FromU2ME, the above script work really well. Thanks again!

Now I want a way to remove "- Microsoft Internet Explorer" from the title bar. I just want my title to appears. Anyone can help?

Thanks
×

Success!

Help @pango spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...