/    Sign up×
Community /Pin to ProfileBookmark

Need help on Javascript

I want to bring a particular jsp in a website to the front. i.e., That jsp is present as a link in the same website. I want to bring it to the home page on login to that particular website.
window.open takes the url of the website as a parameter.But this is just a link in that site. Can anyone help me out with this? Thanks in advance

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@toicontienFeb 21.2008 — Try this:
/**
* @function popup
* Creates an accessible JavaScript pop up window link. Allows JavaScript-
* enabled browsers to open links in a new window and control its
* appearance, while allowing non JavaScript browsers to follow the link.
*
* @param el (object, required)
* Node reference to the clicked link.
*
* @return boolean
* If an invalid node reference is passed, true is returned to all the
* mouse click or pressed key event to continue. If all is well, a false
* value is returned to nullify the link click.
*/
function popup(el, opts) {
if (!el) {
return true;
}
var target = '_blank', url = el.href;
var win;
if (!opts) {
opts = '';
}
if (el.target !== '') {
target = el.target;
}
win = window.open(url, opts, target);
win.focus();
win = null;
return false;
}

Use it like this:
[code=html]<a href="http://www.google.com/" onclick="return popup(this, 'width=400,height=400,toolbar=0');" target="_blank">Google</a>[/code]

The line of code [B]win.focus();[/B] puts focus on the newly created window.
Copy linkTweet thisAlerts:
@cncncnauthorFeb 22.2008 — hi thx for ur help...i tried the script...works fine... this script works for onClick() but i want to open a pop up page using onLoad event.How to give the JSP name to the window.open method??
Copy linkTweet thisAlerts:
@toicontienFeb 22.2008 — Use the amended popup code below:
function popup(url, target, opts, cancelEvent) {
var win;
if (!target) {
var target = "_blank";
}
if (!opts) {
var opts = "";
}
win = window.open(url, opts, target);
win.focus();

if (cancelEvent) {
win = null;
return false;
} else {
return win;
}
}

Now a couple different ways of using this function:
[code=html]<body onload="popup('http://www.google.com/', '_blank', 'width=400,height=400,toolbar=0');">[/code]
OR
[code=html]<a href="http://www.google.com/" target="_blank" onclick="return popup(this.href, this.target, 'width=400,height=400,toolbar=0', true);">Google</a>[/code]

OR

[code=html]<head>
<script type="text/javascript">
window.onload = function() {
popup('http://www.google.com/', '_blank', 'width=400,height=400,toolbar=0');
};
</script>
</head>[/code]
Copy linkTweet thisAlerts:
@cncncnauthorFeb 22.2008 — Thx a ton! wil chk dis out and let yu kno incase of doubts..
×

Success!

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