PDA

View Full Version : Sports Block


Switch17
04-23-2003, 11:58 PM
Hi, I came across this script on the web, and it works great giving you the latest scores, and such for different sports. However, I'm hoping someone can help me with it. Currently, when you choose a score or link, it will open up the page in the same window, taking you off your site. I'm hoping someone can show me how to alter it so that the links open in a new window.

<center><form name="jumpy">
<select name="example" size="1" onChange="gone();">
<option value="http://www.sportsline.com/nfl/box-scoreboards">nfl</option>
<option value="http://www.sportsline.com/mlb/box-scoreboards">mlb</option>
<option value="http://www.sportsline.com/nhl/box-scoreboards">nhl</option>
<option value="http://www.sportsline.com/nba/box-scoreboards">nba</option>
<option value="http://www.sportsline.com/u/includes/script/PGA_leader_inc.htm">pga</option>
<option value="http://www.sportsline.com/collegefootball/box-scoreboards">NCAA Football</option>
<option value="http://www.sportsline.com/collegebasketball/box-scoreboards">NCAA Basketball</option>
<option value="http://www.vegasinsider.com/u/includes/script/odds_inc.htm">Las Vegas Odds</option>
</select>
</form><center>
<p>Courtesy of CBS Sportsline<p>

<script language="javascript">
var displaymode=0;

<!-- This adds the iframe -->

var iframecode="<center><iframe id='external' style='width:155;height:220;' src='http://www.sportsline.com/nfl/box-scoreboards' scrolling='auto' border=0 marginwidth=1 marginheight=1 align=center frameborder=0></iframe></center>";

if (displaymode==0) {
document.write(iframecode);
}

function gone(){
var selectedurl=document.jumpy.example.options[document.jumpy.example.selectedIndex].value;
if (document.getElementById&&displaymode==0) {
document.getElementById("external").src=selectedurl;
} else if (document.all&&displaymode==0) {
document.all.external.src=selectedurl;
} else {
if (!window.win2||win2.closed) {
win2=window.open(selectedurl);
} else {
win2.location=selectedurl;
win2.focus();
}
}
}
</script>

glenngv
04-24-2003, 03:02 AM
win2=window.open(selectedurl,"_blank");

Switch17
04-24-2003, 03:32 AM
Thanks, but I had tried that already and just re-tried it again. That still doesn't open it into a new window like I hoped it would.

glenngv
04-24-2003, 03:45 AM
it is because, if the browser you are using is IE5+/NS6+, the page will be opened inside the iframe (inline frame). if NS4, then it will be opened in a new window

MAXX
04-25-2003, 11:47 AM
heya

I have just one question ...
this function open url in new window
win2=window.open(selectedurl,"_blank");

what should I use to open url in same window??
I know that I can use:
win2=location.replace(url)

but if I use that, then I lost replaced page, which is not good for me.

It should work like this:
<a href="url">link</a>
but i want to call javascript to open that url in the same window.

I would be greateful for any tips, and that realy shouldn't be a problem for you guys :)

thanx in advance
maxx

MAXX
04-25-2003, 01:24 PM
well I made it


it goes like this

var url = window.open("url","_self")


maxx