/    Sign up×
Community /Pin to ProfileBookmark

need to access DOM window element

This might be kindergarten stuff…

I have a document that I want to always open in a window of a certain size, without any toolbar, menubar, locationbar. I found some PHP reference material about DOM, but I can’t make head or tail of it.

Like for example, can I put code right into the document, before any HTML output, that controls those properties? Or do I have to put code in the previous document that opens and configures the window, then opens the document? Can someone get me started?

to post a comment
PHP

25 Comments(s)

Copy linkTweet thisAlerts:
@AJAXNov 03.2005 — That's a job for javascript!
Copy linkTweet thisAlerts:
@strBeanauthorNov 03.2005 — I realize that I can do this with javascript. Are you saying there's really no way to do it with PHP?
Copy linkTweet thisAlerts:
@SpectreReturnsNov 04.2005 — Seeing as PHP is serverside, there is no way to do it.
Copy linkTweet thisAlerts:
@winged1Nov 04.2005 — php will do it, by serving the appropriate javascript code.
Copy linkTweet thisAlerts:
@strBeanauthorNov 04.2005 — Hi

Thanks for the responses. I'm having an email nightmare, and didn't get the alerts.

I'm only still catching on to the concept of server-side/client-side, but I understand now that this was a silly question. I am doing everything I can without javascript, and I thought that I had discovered that the DOM object.method that I wanted will work as straight HTML. In other words, I put the window.open method straight into the onclick event argument of an <a> element, without calling a javascript function, and I thought that meant it would work even if the user's browser didn't have javascript enabled. I just tested it by disabling javascript in a browser, and found that, alas, it doesn't execute.

Hmm, interesting stuff.
Copy linkTweet thisAlerts:
@sitehatcheryNov 05.2005 — Maybe I'm missing the point of what you're trying to do. But, could you just use an iframe tag? It's just a simple HTML tag. You can place it anywhere within your document, specify the size, border type, whether or not you want scroll bars, etc. Is this what you are trying to accomplish?
Copy linkTweet thisAlerts:
@bokehNov 05.2005 — In other words, I put the window.open method straight into the onclick event argument of an <a> element, without calling a javascript function[/QUOTE]Sorry to disappoint you but that is javascript.
Copy linkTweet thisAlerts:
@strBeanauthorNov 05.2005 — Maybe I'm missing the point of what you're trying to do. But, could you just use an iframe tag? It's just a simple HTML tag. You can place it anywhere within your document, specify the size, border type, whether or not you want scroll bars, etc. Is this what you are trying to accomplish?[/QUOTE]

I've not used iframes. When I read about them, it looked like they act like frames, that is, they display content in a frame within the existing browser window. Am I right? What I want is a new window, without any toolbar, status bar, or location bar, and a close button.
Copy linkTweet thisAlerts:
@bokehNov 05.2005 — What I want is a new window, without any toolbar, status bar, or location bar, and a close button.[/QUOTE]Then you need javascript.
Copy linkTweet thisAlerts:
@strBeanauthorNov 05.2005 — Sorry to disappoint you but that is javascript.[/QUOTE]

Yes, that's what my experiment suggested. That even without a <script> tag, it's javascript.

So, I'm going to get rid of the hyperlink that calls the window.open method, and put in a regular one, so that browsers that don't have js enabled will still open the document. Now I'm wondering if I can put javascript right into the document (the one I was trying to open in a stripped-down window) that will remove the toolbar and locationbar from the document's current window.

Thanks for bearing with me.
Copy linkTweet thisAlerts:
@bokehNov 05.2005 — that will remove the toolbar and locationbar from the document's current window.[/QUOTE] Most people adjust their browser as they like it and don't look favourably on websites that make changes especially without permission. Infact it is precisely this type of terrorist tactic that has created javascript's bad reputation.
Copy linkTweet thisAlerts:
@strBeanauthorNov 05.2005 —  this type of terrorist tactic [/QUOTE]

Excuse me, which type of [i]what[/i]?

As a web beginner, trying to understand the uses of different kinds of scripting, I've gotten some good information from this thread, but I think that'll about do it.
Copy linkTweet thisAlerts:
@bokehNov 05.2005 — I'm sorry if you don't like my choice of words but in my opinion taking over someones browser by either opening windows or somehow else interfering with the interface is only one step away from virus type activity.
Copy linkTweet thisAlerts:
@strBeanauthorNov 05.2005 — Point taken. Thanks for all your help.
Copy linkTweet thisAlerts:
@ShrineDesignsNov 05.2005 — this will work regardless of js enabled or not[code=html]<a href="http://www.google.com/" onclick="window.open(this.href, '_blank'); return false;">link</a>[/code]
Copy linkTweet thisAlerts:
@strBeanauthorNov 05.2005 — Oh, okay, now that's kinda int'resting. I had a "#" value for the href attribute, which meant that without js, the click did nothing. The only problem left now is there's a close button on the document that opens, which of course does nothing without js. Not a big problem...but it figures into my design.

What does the command 'return false' do?
Copy linkTweet thisAlerts:
@bokehNov 05.2005 — this will work regardless of js enabled or not[code=html]<a href="http://www.google.com/" onclick="window.open(this.href, '_blank'); return false;">link</a>[/code][/QUOTE]That only opens a new window if javascript is enabled. That means if the current window and the new window are expected to operate as a pair that would not be possible if javascript were to be disabled.
Copy linkTweet thisAlerts:
@strBeanauthorNov 06.2005 — That only opens a new window if javascript is enabled. That means if the current window and the new window are expected to operate as a pair that would not be possible if javascript were to be disabled.[/QUOTE]

Right, but I've tried Shrine's idea, and if I add the target attribute [CODE]$hitsLink = '<a target="_blank" href="CIB_hits.php?briefID='.$briefID.'"
onclick="window.open('CIB_hits.php?briefID='.$briefID.'','_blank','height=400,
left=200, location=no, menubar=no, resizable=no, scrollbars=yes, toolbar=no,
top=200, width=600'); return false;">check Director hits</a>';
[/CODE]
then at least it opens a new window when js isn't enabled, albeit with all the window trimmings and a nonworking close button, which I'm mulling over.

BTW, what does the [COLOR=Navy][B]return [/B] [/COLOR] statement do?
Copy linkTweet thisAlerts:
@strBeanauthorNov 06.2005 — I take it back.

With js enabled, my code above opens 2 windows. Oh well.
Copy linkTweet thisAlerts:
@bokehNov 06.2005 — if I add the target attribute[/QUOTE] Target is deprecated. It validates in HTML 4.01 but is invalid in any later standard.

BTW, what does the [COLOR=Navy][B]return [/B] [/COLOR] statement do?[/QUOTE]When you click on a link it is supposed to do [I]something[/I]. [B]return false [/B]stops [I]something [/I]from being executed. In your case it prevents the existing window from loading the link.
Copy linkTweet thisAlerts:
@strBeanauthorNov 06.2005 — Target is deprecated. [/QUOTE]I didn't know that. What's the new way to have a link open in a new window?

I take it back.

With js enabled, my code above opens 2 windows. Oh well.[/QUOTE]
I take it back again. There was a stray character in what I posted. Actually it works.
Copy linkTweet thisAlerts:
@bokehNov 06.2005 — I didn't know that. What's the new way to have a link open in a new window?[/QUOTE]It also doesn't validate in HTML 4.01 strict. There is no replacement as such. The recommendation is what ShrineDesigns posted (javascript).
Copy linkTweet thisAlerts:
@strBeanauthorNov 06.2005 — I wonder why. Do you think the decision to deprecate it was made out of respect for users' browsing preferences, like what you referred to earlier?
Copy linkTweet thisAlerts:
@bokehNov 06.2005 — It is a tool for use with frames. Since frames is deprecated (i.e no future standard will incorparate them) it seems logical for target to be deprecated in tandem.
Copy linkTweet thisAlerts:
@strBeanauthorNov 08.2005 — That makes sense; I used it when I had frames.

However, the attribute works as a way to control whether a new window is spawned for a hyperlink, and works without frames too. I'm sure I'm not the only person who's used it this way. My style has been to add target="_blank" when the hyperlink is outside my domain, or when the link is to a PDF or other document that is provided for printing or saving. Nothing provided for this functionality in newer versions of HTML...that's odd. It seems a good service to open a new window for an external domain; the new site will likely not have a link back to my site, so target="_blank" saves the user some potential inconvenience (including the user who doesn't have javascript enabled.) I still don't understand the decision.
×

Success!

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