You are missing our premiere tool bar navigation system! Register and use it for FREE!

NukeCops  
•  Home •  Downloads •  Gallery •  Your Account •  Forums • 
Readme First
- Readme First! -

Read and follow the rules, otherwise your posts will be closed
Modules
· Home
· FAQ
· Buy a Theme
· Advertising
· AvantGo
· Bookmarks
· Columbia
· Community
· Donations
· Downloads
· Feedback
· Forums
· PHP-Nuke HOWTO
· Private Messages
· Search
· Statistics
· Stories Archive
· Submit News
· Surveys
· Theme Gallery
· Top
· Topics
· Your Account
Who's Online
There are currently, 61 guest(s) and 1 member(s) that are online.

You are Anonymous user. You can register for free by clicking here
Nuke Cops :: View topic - How To Insert JavaScript Into Modules/Blocks [ ]
 Forum FAQ  •  Search  •   •  Memberlist  •  Usergroups   •  Register  •  Profile •    •  Log in to check your private messages  •  Log in

 
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
Author Message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Wed May 07, 2003 8:13 am Reply with quoteBack to top

This question has been asked and answered more times than I can recall. There is a PHP built in way to do this that is very simple and fool-proof.

First I will show you an example and then explain it.
Code:

$someVarName = <<<_JSCODE_
<script>alert('Hello World');</script>
_JSCODE_;

echo $someVarName;

That's it! You simply insert your JavaScript code as you use it in your HTML document and drop it in. You do not have to escape any quotes or anything special. If it works in native HTML, it should work here.

Now for a caveat. You can use PHP variables in the code WITHOUT using the <? ?> tags. Here would be an example of that.
Code:

$messageText = 'Hello World';

$someVarName = <<<_JSCODE_
<script>alert('$messageText');</script>
_JSCODE_;

echo $someVarName;

Now, if you were using this in a block, you need to assign all content to the $content variable. You could do this in a separate line of code, like this
Code:
$messageText = 'Hello World';

$someVarName = <<<_JSCODE_
<script>alert('$messageText');</script>
_JSCODE_;

$content = $someVarName;
or just assign the block to $content instead of $someVarName like this.
Code:
$messageText = 'Hello World';

$content = <<<_JSCODE_
<script>alert('$messageText');</script>
_JSCODE_;


There is only 1 very important syntactical rule for usage. In my example _JSCODE_ is analogous to a BLOCK TAG. These tags can be named whatever you want, as can the $someVarName. However, the ending block tag MUST be left aligned AND there can be no character EXCEPT a carriage return after either of the block tags.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
ferrari4ever
Corporal
Corporal


Joined: May 30, 2003
Posts: 63

Location: The Netherlands

PostPosted: Mon Jun 02, 2003 6:20 am Reply with quoteBack to top

thanx...


Last edited by ferrari4ever on Mon Jun 02, 2003 8:27 am; edited 1 time in total
Find all posts by ferrari4everView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jun 02, 2003 6:27 am Reply with quoteBack to top

Not again. There are enough examples given. Search the forums!

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
ferrari4ever
Corporal
Corporal


Joined: May 30, 2003
Posts: 63

Location: The Netherlands

PostPosted: Mon Jun 02, 2003 7:04 am Reply with quoteBack to top

Raven wrote:
Not again. There are enough examples given. Search the forums!


Great thanks for your help... Evil or Very Mad
Find all posts by ferrari4everView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jun 02, 2003 7:07 am Reply with quoteBack to top

Feed a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.

I have provide examples for all cases. Even as recently as yesterday that answers your EXACT question. I have provided you your answer already.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
chatserv
General
General


Joined: Jan 12, 2003
Posts: 3128

Location: Puerto Rico

PostPosted: Mon Jun 02, 2003 7:20 am Reply with quoteBack to top

I just had to grab that line, refrain from taking this to court for now as my lawyer went on a strike.

_________________
Feed a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
ScriptHeaven | NukeResources
Find all posts by chatservView user's profileSend private messageVisit poster's website
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jun 02, 2003 7:31 am Reply with quoteBack to top

Let me know when it's convenient Laughing

Author unknown on the quote. Don't you just love it when you supply the answers and still get blasted? I want a raise! I deserve at least a case of Pepsi a month.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
chatserv
General
General


Joined: Jan 12, 2003
Posts: 3128

Location: Puerto Rico

PostPosted: Mon Jun 02, 2003 7:35 am Reply with quoteBack to top

Something in that general direction may be coming up soon, now, you do have a point on what transpired in this post, not the first time i see it though, surely won't be the last.

_________________
Feed a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
ScriptHeaven | NukeResources
Find all posts by chatservView user's profileSend private messageVisit poster's website
chris-au
Elite Nuker
Elite Nuker


Joined: Jan 31, 2003
Posts: 717


PostPosted: Thu Jun 05, 2003 5:51 pm Reply with quoteBack to top

Only in a perfect world, where everybody is fortunately enough to live near water where fish can survive in this wonderfull polluted world, could the following be believable:

Quote:
Feed a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime
Find all posts by chris-auView user's profileSend private messageVisit poster's website
Densmore
Nuke Cadet
Nuke Cadet


Joined: Jun 23, 2003
Posts: 6


PostPosted: Mon Jun 23, 2003 3:36 pm Reply with quoteBack to top

I just wanted to stop and take a moment to say THANK YOU for all the work you guys put in on this stuff! It takes time, effort, comittment, brain power and a ton of patience to moderate forums of this nature and I thank you all now for all of the help I am about to receive! Smile
Find all posts by DensmoreView user's profileSend private message
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Mon Jun 23, 2003 4:01 pm Reply with quoteBack to top

Actually 2.34875 tons, but whose counting Laughing

Thanks from all the staff at NC!

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
Rafael
Corporal
Corporal


Joined: May 24, 2003
Posts: 71


PostPosted: Mon Jun 30, 2003 9:15 pm Reply with quoteBack to top

We just may have to create a separate forum where we can lavish praise and kudos on the nukecops staff! Great job guys! Your help may often go uncommented but definitely not unappreciated. Very Happy
Find all posts by RafaelView user's profileSend private message
Kenshin_The_Battousai
Nuke Soldier
Nuke Soldier


Joined: Jul 25, 2003
Posts: 21

Location: Columbus, Ohio

PostPosted: Tue Jul 29, 2003 3:29 pm Reply with quoteBack to top

will the work for the messages too for teh home page
Find all posts by Kenshin_The_BattousaiView user's profileSend private messageSend e-mailVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger
Raven
General
General


Joined: Mar 22, 2003
Posts: 5233

Location: USA

PostPosted: Tue Jul 29, 2003 4:32 pm Reply with quoteBack to top

Kenshin_The_Battousai wrote:
will the work for the messages too for teh home page
Please restate you question.

_________________
Those who hear not the music think the dancers mad.
Raven Web Hosting|My Scripts & Stuff
Find all posts by RavenView user's profileSend private messageVisit poster's website
leezard
Nuke Soldier
Nuke Soldier


Joined: Aug 04, 2003
Posts: 16


PostPosted: Mon Aug 04, 2003 2:28 pm Reply with quoteBack to top

Just had to register and thank Raven, I've been trying to get some javascript to work in a block for a week now, took a lot of trila and error but finally got it done thanks to his tips.
Find all posts by leezardView user's profileSend private message
Display posts from previous:      
Post new topic  Reply to topicprinter-friendly view
View previous topic Log in to check your private messages View next topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Powered by phpBB © 2001, 2005 phpBB Group

Ported by Nuke Cops © 2003 www.nukecops.com
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::
Powered by · TOGETHER TEAM srl ITALY http://www.togetherteam.it · DONDELEO E-COMMERCE http://www.DonDeLeo.com
Web site engine's code is Copyright © 2002 by PHP-Nuke. All Rights Reserved. PHP-Nuke is Free Software released under the GNU/GPL license.
Page Generation: 0.996 Seconds - 190 pages served in past 5 minutes. Nuke Cops Founded by Paul Laudanski (Zhen-Xjell)
:: FI Theme :: PHP-Nuke theme by coldblooded (www.nukemods.com) ::