 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 22nd, 2010, 06:17 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
But what is it that you're ultimately trying to accomplish? Do you want to display the JavaScript to the end user? Or do you want to execute it? You can't do both at the same time directly. You seem to be very confused about a) what it is you eventually want and b) how the techniques you're using work.
When you want to *display* the JavaScript to the user, use HTML encoding or <xmp>. This ignores the meaning of the JavaScript and simply displays it to the user.
If you want to *execute* it, make sure it's valid JavaScript. Don't mix with HTML.
Don't try to do both as you can't, directly. Code is either code that is to be executed, or text that is visible on screen.....
Imar
|
|

March 22nd, 2010, 06:25 PM
|
|
Authorized User
|
|
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
|
|
http://ads.adbrite.com/mb/text_group...3330305f323530
I saw this output of this url is a code appear to user and also is called inside a javascript code, so how could those did that?
I want to do the same..
__________________
ASP.NET & C#
|
|

March 22nd, 2010, 06:32 PM
|
|
Authorized User
|
|
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
|
|
paste this on a new html
Code:
<!-- Begin: AdBrite, Generated: 2010-02-12 15:29:54 -->
<script type="text/javascript">
var AdBrite_Title_Color = '0000FF';
var AdBrite_Text_Color = '000000';
var AdBrite_Background_Color = 'FFFFFF';
var AdBrite_Border_Color = 'CCCCCC';
var AdBrite_URL_Color = '008000';
try{var AdBrite_Iframe=window.top!=window.self?2:1;var AdBrite_Referrer=document.referrer==''?document.location:document.referrer;AdBrite_Referrer=encodeURIComponent(AdBrite_Referrer);}catch(e){var AdBrite_Iframe='';var AdBrite_Referrer='';}
</script>
<script type="text/javascript">document.write(String.fromCharCode(60,83,67,82,73,80,84));document.write(' src="http://ads.adbrite.com/mb/text_group.php?sid=1528582&zs=3330305f323530&ifr='+AdBrite_Iframe+'&ref='+AdBrite_Referrer+'" type="text/javascript">');document.write(String.fromCharCode(60,47,83,67,82,73,80,84,62));</script>
<div><a target="_top" href="http://www.adbrite.com/mb/commerce/purchase_form.php?opid=1528582&afsid=1" style="font-weight:bold;font-family:Arial;font-size:13px;">Your Ad Here</a></div>
<!-- End: AdBrite -->
__________________
ASP.NET & C#
|
|

March 22nd, 2010, 06:33 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
All I see is a PHP document with compressed script in it. When I click your link I get a download dialog. I am not, in any way, seeing what you're describing. Yes, I see something like document.writeln('<script .... but that will simply write into the document when executed, not display it.
You could have cleared this up ages ago if only you were providing the right information.
Imar
|
|

March 22nd, 2010, 06:35 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
|
|

March 22nd, 2010, 06:37 PM
|
|
Authorized User
|
|
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
All I see is a PHP document with compressed script in it. When I click your link I get a download dialog. I am not, in any way, seeing what you're describing. Yes, I see something like document.writeln('<script .... but that will simply write into the document when executed, not display it.
You could have cleared this up ages ago if only you were providing the right information.
Imar
|
please open the url with firefox to see the code
__________________
ASP.NET & C#
|
|

March 23rd, 2010, 03:12 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
please open the url with firefox to see the code
|
The end result is the same: I get a page with source code that is *not* executable JavaScript. All you see there is plain text, that happens to be JavaScript. It's not executed when you browse to that page, but only displayed.If you add a script reference to this file, it's executed but not displayed.
So, what you're looking for is a plain page that outputs plain JavaScript. You can use a standard . js file for that or an ASPX file that outputs the right code. (You may need to clear the current response and set the content type). However, this has all been discussed in previous threads many times before and it didn't seem to help you. Since you refuse to describe what it is you're trying to do, I cannot help you any further.
Imar
|
|

March 23rd, 2010, 06:11 AM
|
|
Authorized User
|
|
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Imar
The end result is the same: I get a page with source code that is *not* executable JavaScript. All you see there is plain text, that happens to be JavaScript. It's not executed when you browse to that page, but only displayed.If you add a script reference to this file, it's executed but not displayed.
So, what you're looking for is a plain page that outputs plain JavaScript. You can use a standard . js file for that or an ASPX file that outputs the right code. (You may need to clear the current response and set the content type). However, this has all been discussed in previous threads many times before and it didn't seem to help you. Since you refuse to describe what it is you're trying to do, I cannot help you any further.
Imar
|
what I want to do is an advertisement network systme.
the publishers can get a javascript code that's embed to their websites to generate ads from our company server.
part of the javascrip code is generated from our company/app, since that is to accomplish the right ads for the right publisher.
till now you can response me that it's clear and I will continue clarifying.
Thanks Imar.
__________________
ASP.NET & C#
|
|

March 23rd, 2010, 06:19 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
In that case, simply return a complete, valid JavaScript. There is *no need* to display it; it only needs to be executed, so any ordinary JS file will do.
Imar
|
|

March 23rd, 2010, 07:38 AM
|
|
Authorized User
|
|
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
|
|
but I found it difficult for js to retreive the data from sql server, and I'm not familliar with
__________________
ASP.NET & C#
|
|
 |