/    Sign up×
Community /Pin to ProfileBookmark

help with window object

very simple question..

what is the syntax used to access a window by its name?

say my code looks like this:

[code]
function openNewWindow(winName){

newWindow = window.open(”,winName,’width=450,height=300,resizable=yes,scrollbars=no,toolbars=no,top=50,left=100′);
content = “<html><head>”;
content += “<script src=’js.js’></script>”;
content += “</head>”;
content += “<body><a href=’javascript:;’ onclick=’editWindow(“”+newWindow+””)’>edit my window</a></body>”;
content += “</html>”;

newWindow.document.write(content);
newWindow.document.close();

}
[/code]

function editWindow(newWindow) inside js.js receives newWindow as a window object but when I try to do

newWindow.focus() inside js.js, it says newWindow.focus() is not a function?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Logic_AliJun 24.2008 — onclick='editWindow(""+newWindow+"")[/quote]You're passing the reference as a string.
Copy linkTweet thisAlerts:
@YourChildauthorJun 24.2008 — Please do show me how to pass the reference as an object, I have been so stuck on this all day ahhH!!!! (*deep breath)

I tried doing

onclick='editWindow("+newWindow+")'

and it says: missing ] after element list and I have no idea what this means?
Copy linkTweet thisAlerts:
@Logic_AliJun 24.2008 — Please do show me how to pass the reference as an object[/quote]Try:
onclick='editWindow(opener.newWindow)'
×

Success!

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