Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
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
 
Old March 22nd, 2010, 06:17 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 22nd, 2010, 06:25 PM
Authorized User
 
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

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#
 
Old March 22nd, 2010, 06:32 PM
Authorized User
 
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

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#
 
Old March 22nd, 2010, 06:33 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 22nd, 2010, 06:35 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
paste this on a new html
I don't think so.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 22nd, 2010, 06:37 PM
Authorized User
 
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
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#
 
Old March 23rd, 2010, 03:12 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 23rd, 2010, 06:11 AM
Authorized User
 
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
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#
 
Old March 23rd, 2010, 06:19 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 23rd, 2010, 07:38 AM
Authorized User
 
Join Date: Feb 2008
Posts: 89
Thanks: 13
Thanked 0 Times in 0 Posts
Default

but I found it difficult for js to retreive the data from sql server, and I'm not familliar with
__________________
ASP.NET & C#





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding meta-tags in aspx page reach_reema ASP.NET 2.0 Basics 0 September 10th, 2008 01:49 AM
html(aspx) web page sivkum Javascript 1 January 11th, 2007 01:53 AM
convert Html in aspx page prashantraizada2002 ASP.NET 1.0 and 1.1 Basics 1 June 24th, 2006 04:55 PM
Add XSLT transformed XML (html) on an aspx page humour XSLT 2 September 30th, 2004 05:13 AM
Cookie Error when run web page test.aspx C#.net minhpx General .NET 1 August 10th, 2004 01:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.