There is a script I am using....A Media Gallery...everytime I put in a javascript, it does not work. When I put

<script type="text/javascript"
src="http://www.example.com/js/swfobject.js">
</script>
<script language="javascript"
src="http://www.example.com/js/player.js">
</script>
<script language="javascript">
var config = new Array();
config["width"] = 400;
config["height"] = 300;
config["clientId"] = "example";
config["bgColor"] = "#FFFFFF";
config["playList"] = "1191";
showSanagaPlayer(config);
</script>

I recieve this when I view the source of the script

<script type="text/javascript"<br />
src="<A href="http://www.example.com/js/swfobject.js"><br">http://www.example.com/js/swfobject.js"><br />
</script><br />
<script language="javascript"<br />
src="<A href="http://www.example.com/js/player.js"><br">http://www.example.com/js/player.js"><br />
</script><br />
<script language="javascript"><br />
var config = new Array();<br />
config["width"] = 400;<br />
config["height"] = 300;<br />
config["clientId"] = "example";<br />
config["bgColor"] = "#FFFFFF";<br />
config["playList"] = "1191";<br />
showSanagaPlayer(config);<br />
</script>

Is there anything I can do for it to ignore <br />
Note...the script was intended for html

It looks to me like you entered this somewhere in your mediagalary, but that it got parsed. To because that a tag was wrapped around the URL's. Bit weird is the <br"> and that it didn't close the a tag, if it were a parser.

So I ask you, did you nativly pasted this into PHP like:

<?php
//code here
?>
<script type="text/javascript"
src="http://www.example.com/js/swfobject.js">
</script>
<script language="javascript"
src="http://www.example.com/js/player.js">
</script>
<script language="javascript">
var config = new Array();
config["width"] = 400;
config["height"] = 300;
config["clientId"] = "example";
config["bgColor"] = "#FFFFFF";
config["playList"] = "1191";
showSanagaPlayer(config);
</script>
<?php
//code here
?>

or did you enter this somewhere in a form in the media galary your using. If you didn't enter it in a form it's still theoraticly possible to style it with ob_start() and output buffer functions, seems unlikely though. You might wanna add what gallery your using.

When I add this to the form in the php scripts which is

<script type="text/javascript"
src="">
</script>
<script language="javascript"
src="">
</script>
<script language="javascript">
var config = new Array();
config["width"] = 400;
config["height"] = 300;
config["clientId"] = "example";
config["bgColor"] = "#FFFFFF";
config["playList"] = "1191";
showSanagaPlayer(config);
</script>

I recieve this when I view the source of the website I get

<script type="text/javascript"<br />
src="<A href="<A href="http://www.example.com/js/swfobject.js"><br">http://www.example.com/js/swfobject.js"><br">
</script><br />
<script language="javascript"<br />
src="<A href="<A href="http://www.example.com/js/player.js"><br">http://www.example.com/js/player.js"><br">
</script><br />
<script language="javascript"><br />
var config = new Array();<br />
config["width"] = 400;<br />
config["height"] = 300;<br />
config["clientId"] = "example";<br />
config["bgColor"] = "#FFFFFF";<br />
config["playList"] = "1191";<br />
showSanagaPlayer(config);<br />
</script>

I think there must be a code in the php that adds <br /> when I put in my code

Where are you putting in the JS script? Directly into a PHP file? HTML file?
Are you entering it via a form?

The New Lines are being parsed into <br /> tags somewhere..

I am entering into a form a form...

I have included an attachment of the index.php and some of the main files that can contain The New Lines being parsed into <br /> tags somewhere.... I have tried messing with it but no luck. Can someone help

The form handler uses the function nl2br() on the content it receives.
You'll have to remove that or upload your script via ftp or some other method.

or

Put the JS in a file and upload the file anywhere on the web.

Plase <script src="http://example.com/js_file.js"></script>

in the form you're using. make sure it links to the js file. That way the form won't corrupt your js.

what gallery are you using by the way. It is a stand alone gallery or on top of another app?

I am using Photokorn Media Gallery.. I have posted some files that might contain it. Can you help me to remove function nl2br() from the script.

Can someone help with the script

In the form you are uploading your script, look at the HTML source. The form will have an "action" attribute. This points to the form handler. This file is the one thats changing the code you're putting in. Post the file contents here or put it in a text editor and search for nl2br.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.