/    Sign up×
Community /Pin to ProfileBookmark

Opening a link in a new window

I have a page of links with 14 drop down menus for different categories of links: [URL=http://www.myprojectcar.net/menu3.html]my menu page[/URL] My question is this: is it possible to force the links to open in a new window like the target=new in html? I would like for people to not leave my site completely if possible.

Cosmosis the Clueless

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@blade69Oct 24.2004 — I'm having kinda the same problem, [URL=http://www.mycasinonline.biz/]My site[/url] is in frames in html, and I'm using flash links. I need to set these javascript links to open in a new window, otherwise they open inside my webpage in the main frame.
Copy linkTweet thisAlerts:
@thedosmannOct 24.2004 — I assume you Tried

<OPTION value=window.open("installed.html","","","")>Installed Parts</OPTION>

and it didn't work?
Copy linkTweet thisAlerts:
@blade69Oct 24.2004 — I just learned html, so java is still greek to me. And so now for the really stupid question: where would I insert that line?:p
Copy linkTweet thisAlerts:
@thedosmannOct 24.2004 — First just were I did. I just copied one of your options and inserted the window open.

If that doesn't work I would need to look closer at whay your actually doing.
Copy linkTweet thisAlerts:
@cosmosisauthorOct 24.2004 — You can never assume anything where I am concerned except that I will always have questions. I know nothing of javascript except that I can get free scripts online that will work for me. I tried your idea and it did not work. When I put the window.open inside the OPTION tag and tried the menu I got the "page not found" thing. I can see how the window.open thing would work if you had one submit button for each link you are trying to create. Doesnt seem to work with multiple links like I have.
Copy linkTweet thisAlerts:
@blade69Oct 24.2004 — Ahhh... I see, that line is out of comosis's source code, and looking at it, his script is much different than mine. ?
Copy linkTweet thisAlerts:
@thedosmannOct 24.2004 — Try it with the full address

<OPTION value=window.open("http://www.myprojectcar.net/installed.html","","","")>Installed Parts</OPTION>

the ""'s are options for window size etc.
Copy linkTweet thisAlerts:
@blindrainOct 24.2004 — [CODE] <SCRIPT language=JavaScript>
<!-- Begin
function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.open(URL);
}
// End -->
</SCRIPT>



<!--Options--> <FORM name=form>
<SELECT style="font-size:8pt;background:#5500ff;color:#ff0000;padding:2px" class=initial3 size=1 name=site>
<OPTION value="index.html" selected>Go to...
<OPTION value="../downloads/index.html">Downloads
<OPTION value="..imagesindex.html">Images
<OPTION value="file:///A:/">A Drive.
<OPTION value="../slideshowindex.html">Slide Show
<OPTION value="../mathindex.html">Math Page
<OPTION value="../musicindex.html">My Favorite Music
<OPTION value="../poetryindex.html">Poetry
<OPTION value="Table.html">Photos
<OPTION value="Resume.html">Resume
<OPTION value="http://www.yahoo.com">Yahoo.com
</OPTION>
</SELECT>
<input type="button" value="Go" onclick="formHandler()">
</FORM>
</CENTER>


<!-- onchange=javascript:formHandler() copy this to the select tag if you don't want to have to click on the button-->[/CODE]
you'll find this @[URL=http://home.comcast.net/~rfdwhitacre]home.comcast.net/~rfdwhitacre[/URL] Except it does not open in a new window I modified it a little just so that it would open in new window i took out "window.location.href = URL;" and put in "window.open(URL);"
Copy linkTweet thisAlerts:
@cosmosisauthorOct 24.2004 — Well blindrain you certainly answered my prayers! I adopted your code and it works perfectly on my site. Here is the updated menu page with the new code installed: [URL=http://www.myprojectcar.net/menu3a.html]my menus[/URL]

I even figured out how to make multiple scripts work on the same page. Thanks ever so much.

Now for another quick question ... How can I get the text in the choice boxes to be centered? Is there a style tag for that?
×

Success!

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