| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Putting it all together
Let me start with saying that I'm new to JavaScript. I'm trying to add a link to my web page. It should open a new window with no toolbar, scrollbar, location, etc.
I have the following pieces that I can't put together: Code:
<script type="text/javascript">
function open_win()
{
window.open(http://www.mysite.com","my_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no")
}
</script>
Code:
<a target="_blank" href="http://www.mysite.com/"><font size="2" color="#000080"><b>Click here</b></font></a> As you can see I’m having trouble merging JavaScript with HTML. |
|
#2
|
||||
|
||||
|
Quote:
Nah.... easy mistake to make when you've got syntax highlighting off... you haven't enquoted the function arguments properly: Thus: Code:
<script type="text/javascript">
function open_win() {
window.open("http://www.mysite.com","my_window","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no")
}
</script>
Oh, and it helps to use the latest XHTML for the other bit: Code:
linkclassnamegoeshere { size: small; color: #008; font-weight: bold; text-decoration: underline; cursor: hand; }
<span class="linkclassnamegoeshere" onclick="open_win()">Click here</span>
|
|
#3
|
||||
|
||||
|
don't forget the "." when defining your class!
Code:
.linkclassnamegoeshere { size: small; color: #008; font-weight: bold; text-decoration: underline; cursor: hand; }
__________________
ShepherdWeb :: Charging Rhino Wizard I know of no more encouraging fact than the unquestionable ability of man to elevate his life by conscious endeavor. {Henry David Thoreau} § shepherdweb.com § fariswheel productions § reagan administration |
|
#4
|
|||
|
|||
|
Thanks. Got it working. Just out of curiosity, how would I change the cursor to hand without defining a class? Is it possible to do it in the same line with onclick?
Right now this is what I have: Code:
<script type="text/javascript">
function open_win()
{
window.open("http://www.mysite.com","something","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no")
}
</script>
<style>
<!--
.myclass { cursor: hand; }
-->
</style>
And… Code:
<span class="myclass" onclick="open_win()"><img border="0" src="button.gif" width="75" height="15"></span> |
|
#5
|
||||
|
||||
|
hi,
you could use it like this Code:
<span style="cursor:hand" onclick="open_win()"><img border="0" src="button.gif" width="75" height="15"> but the advice you got here, is the best way to do it. ![]()
__________________
Look! Its a ShemZilla ![]() ![]()
|
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Putting it all together |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|