/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Coding

I have the following code, which dynamically writes the code to display images in an ‘Image Viewer’ type window.

[CODE]<!–

PositionX = 100;
PositionY = 100;

if (parseInt(navigator.appVersion.charAt(0))>=4)
{
var isNN=(navigator.appName==”Netscape”)?1:0;
var isIE=(navigator.appName.indexOf(“Microsoft”)!=-1)?1:0;
}
var optNN=’scrollbars=no,width=760,height=500,left=’+PositionX+’,top=’+PositionY;
var optIE=’scrollbars=no,width=740,height=480,left=’+PositionX+’,top=’+PositionY;

function gWindow(imageURL)
{
if (isNN)
{
imgWin=window.open([B]’about:blank'[/B],”,optNN);
}
if (isIE)
{
imgWin=window.open([B]’about:blank'[/B],”,optIE);
}
[COLOR=Red]with (imgWin.document)[/COLOR]
{
writeln(‘<html>’);
writeln(‘<head>’);
writeln(‘<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ >’);
writeln(‘<meta http-equiv=”imagetoolbar” content=”no” >’);
writeln(‘<title>Aylesford School Image Viewer</title>’);
writeln(‘<style>’);
writeln(‘body’);
writeln(‘{‘);
writeln(‘ margin: 0px;’);
writeln(‘}’);
writeln(‘</style>’);
writeln(‘<sc’+’ript>’);
writeln(‘var isNN,isIE;’);
writeln(‘if (parseInt(navigator.appVersion.charAt(0))>=4)’);
writeln(‘{‘);
writeln(‘ isNN=(navigator.appName==”Netscape”)?1:0;’);
writeln(‘ isIE=(navigator.appName.indexOf(“Microsoft”)!=-1)?1:0;’);
writeln(‘}’);
writeln(‘if (isIE)’);
writeln(‘{‘);
writeln(‘ width=100-(document.body.clientWidth-document.images[0].width);’);
writeln(‘ height=100-(document.body.clientHeight-document.images[0].height);’);
writeln(‘ if (isNN)’);
writeln(‘ {‘);
writeln(‘ window.innerWidth=document.images[“Image”].width;’);
writeln(‘ window.innerHeight=document.images[“Image”].height;’);
writeln(‘ }’);
writeln(‘}’);
writeln(‘</sc’+’ript>’);
writeln(‘</head>’)
writeln(”);
writeln(‘<body bgcolor=000000 scroll=”no” onload=”self.focus()”>’);
writeln(‘<img name=”Image” src=”‘+imageURL+'”‘);
writeln(”);
writeln(‘</body></html>’);
}
}
// –>[/CODE]

But instead of referencing ‘about:blank’ (in bold), i’d like to reference another page with some extra styling/coding, but place the above code (obviously removing bits such as <head> and <body> tags) inside a table cell.

I’ve tried giving the table cell in question a name=”imageAnchor” attribbute, and changing

[CODE][COLOR=Red]with (imgWin.document)[/COLOR][/CODE]

to

[CODE]with (imgWin.document.imageAnchor)[/CODE]

But it doesn’t work.

Is this possible, or am I going to need to dynamically code every line, including that from the seperate page?

Thanks very much/…

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 02.2006 — It would depend on the windows/frame structure. In a window structure the child can reference the parent with:window.opener.document.getElementById('objID').src='newImage.gif';
×

Success!

Help @ldoodle 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.19,
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,
)...