/    Sign up×
Community /Pin to ProfileBookmark

Javascript within javascript goes boink!

Trying to have an image shown from another server if the original image isn’t available (webcam online/offline) using this script:

[CODE]document.write(‘<a href=”http://www.cosmicgoober.com/cam/index.htm” onclick=”window.open(‘http://www.cosmicgoober.com/cam/index.htm’,’popup’,’width=340,height=260,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0′);return false” title=”GooberCam!”><img src=”http://192.xx.xx.xx:8000/cam_1.jpg?preview=1″ alt=”Latest Cam image” border=”0″ /></a>’);[/CODE]

Of course it doesn’t work because of the onclick=”window.open(‘http……..

Is there any way to modify this script so that I can get it to do what is needed??

Any help would be EXTREMELY appreciated….

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JavaHead_JonnieFeb 23.2004 — uhh i think it's easy ?

in your .write statement any apostaphies ( ' ) or speech marks ( " ) should be replaced with either " or '

(notice the backslashes!)

try that - only here to help ?
Copy linkTweet thisAlerts:
@spykeauthorFeb 23.2004 — like this??

[CODE]document.write('<a href="http://www.cosmicgoober.com/cam/index.htm" onclick="window.open('http://www.cosmicgoober.com/cam/index.htm','popup','width=340,height=260,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');return false" title="GooberCam!"><img src="http://192.38.238.58:6969/cam_1.jpg?preview=1" alt="Latest Cam image" border="0" /></a>');[/CODE]

dunno if i did it write, but it doesn't work either :-/
Copy linkTweet thisAlerts:
@neil9999Feb 23.2004 — This should work:

[CODE]
document.write('<a href="http://www.cosmicgoober.com/cam/index.htm" onclick="window.open('http://www.cosmicgoober.com/cam/index. htm','popup','width=340,height=260,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,
menubar=no,status=no,left=0,top=0');return false" title="GooberCam!"><img src="http://192.xx.xx.xx:8000/cam_1.jpg?preview=1" alt="Latest Cam image" border="0" /></a>');
[/CODE]


Neil
Copy linkTweet thisAlerts:
@neil9999Feb 23.2004 — So:

[CODE]
<script type="text/javascript">
function something(){
document.write('<a href="http://www.cosmicgoober.com/cam/index.htm" onclick="window.open('http://www.cosmicgoober.com/cam/index. htm','popup','width=340,height=260,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');return false" title="GooberCam!"><img src="http://192.xx.xx.xx:8000/cam_1.jpg?preview=1" alt="Latest Cam image" border="0" /></a>');
}
</script>
</head>

<body>
<a onclick="something()">Something</a>
[/CODE]


I cut out the new lines to make it work. When you cut and paste it, the lines may go back in, so make sure you take them out.

Neil
×

Success!

Help @spyke 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...