Jump to content

Whats wrong with this javascript


ojsimon

Recommended Posts

Hi

this javascript is generated by my code

document.writeln('<head><style>a{color: white; font-size:10px}a:visited{color: white; font-size: 10px;}</style></head><table><tr><tr BACKGROUND="http://localhost:8888/sitewidget/app/webroot/img/border.png"><th><font face="Verdana, Arial" size="4" color="white">Widget</font></th></tr><tr><td><style type="text/css"><!--#frame1 {    width: 400px;    height: 200px;    border: none;    background: white;}--></style><iframe src="/sitewidget/index.php/widget/show/aHR0cDovL3d3dy5iYmMuY28udWsvbG9uZG9uL25ld3Mv/156" name="frame1" id="frame1" scrolling="auto" frameborder="0"></iframe>');</td><tr><tr BACKGROUND="http://localhost:8888/sitewidget/app/webroot/img/border.png"><th><font face="Verdana, Arial" size="20px" color="white" vlink="white"><a href="/sitewidget/index.php/grab/check/aHR0cDovL3d3dy5iYmMuY28udWsvbG9uZG9uL25ld3Mv/156" target="_blank">Get this widget</a></font> <font face="Verdana, Arial" size="2px" color="white"> |</font> <font face="Verdana, Arial" size="20px" color="white" vlink="white"><a href="http://www.websnips.com" target="_blank">Make a widget out of any site</a></font></th></tr></tr></table>'<!-- 0.1254s -->

 

I am trying to run it like this

<html>
<SCRIPT LANGUAGE="JavaScript" SRC="js.html">
</SCRIPT>
</html>

 

I do not know why it is not running as an external file when it is running when you run the file directly?

 

Thanks

 

Link to comment
Share on other sites

I think you need to provide more information.

 

Are you saying that you have server-side code that is writing that first block of code into an external file names js.html?

 

I would agree with Kat, whay are you dynamically creating JavaScript to create variable content. Just use the server-side code to write that dynamica content directly.

Link to comment
Share on other sites

if youre trying to include a external js file yes that would be the right way but it should look like this.

<script type="text/javascript" src="some_file.js"></script>

but i see you're trying to include an html file. if it is suppose to be a html file then a iframe would be the way to do this

<iframe src="http://www.site.com/some_file.html"></iframe>

and if you really don't want a iframe you could solve it with php using fopen or curl

Link to comment
Share on other sites

It doesn't matter what the extension is for a javascript include file. It can be 'js', 'html', 'xyz', 'php' or none at all. I have used 'asp' and 'php' when the include file needed to be dynamic. Although for just plain old consistency 'js' would be best.

 

But, that would not explain the OPs problem.

 

I would try accessing the include file directly (i.e. typing it into the browser) and downloading hte file to your PC. Then open it up in a text editor and confirm it is correct.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.