Click to See Complete Forum and Search --> : Window Targeting
charmon_1
09-05-2003, 12:48 PM
I am trying to open a link in a new window.
I am a javascript beginner.
<script src="/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=881"></script>
The target statement does not work.
Am I missing something.
I tried putting '_blank', and "_blank", and putting target="_blank" outside the src information.
This is an ad program(adcycle) script that is supposed to generate the code to open in a new window but it does not work.
Shampie
09-05-2003, 01:00 PM
something like
window.open("put url here");
hope that will give your answer
//
if you're trying to use target, that only works for frames in same page.
charmon_1
09-05-2003, 01:14 PM
It is still not working.
<script window.open(/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880);></script>
<script window.open("scr='/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880'");></script>
Any other suggestions.
Thank You.
<script type="text/javascript">
window.open("/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880");
</script>Note that I did not include a noscript tag, as uses without javascript quite possibly turned it off to avoid all the popups...
charmon_1
09-05-2003, 01:37 PM
That one worked, but the link opens up automatically.
I want the user to be able to click the link, then have it pop up in a new window.
Can a onmouseup, or onclick be used here?
Thank You.
Ah, then do it like this:
<a href="/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880" onclick="window.open(this.href); return false;">open</a>
Which will continue working for non-JS enabled browsers.
Shampie
09-05-2003, 01:42 PM
jep
you can do it this way:
<script>
function blaat(){
window.open("url here");
}
</script>
inthe object us: onClick="javascript:blaat();"
or onClick="window.open('url here')"
the first one is in case you want to put in additional scripting like message boxes..
Unfortunatly, neither of those options are accessable... :(
Shampie
09-05-2003, 01:50 PM
would it work like this:
<a href="javascript:window.open('/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880')"> ??
charmon_1
09-05-2003, 02:08 PM
Thanks but nothing seems to be working.
The script places the text on the page from the ad program, and the link to the ad page.
<script src="/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880"></script>
I think this is what's giving me such a problem trying to do this.
So if I take the src= information and place it in a href= then I have to manually place text between the anchor tags. But the text needs to be generated by the script.
Only if javascript is enabled. Use the method I posted above to keep the links accessable to non-JavaScript enabled browsers:
<a href="/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880" onclick="window.open(this.href); return false;">open</a>
Shampie
09-05-2003, 02:22 PM
<script src="/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880"></script>
is cgi a valid script file for javascript?
<script language="javascript" src="="/cgi-bin/cycle/adcycle.cgi?gid=5&target=_blank&id=880"></script>
I know it does work of .js extensions (javascipt files)
sorry for rather putting another question between then an answer but it's like learn while trying to me aswell..