MattEvans 473 Veteran Poster Team Colleague Featured Poster

PHP, shtml, ASP etc generally have no requirements for client machine settings, Javascript is more 'risky' than any of these, since it is dependant on client settings.

RSS is just XML; so you could style it directly. Yep, directly. XML can have CSS style. I've never done it, but it can be done. See this page: http://www.xml.com/pub/a/2000/05/03/msie/index.html.

If you do that; you could just load the RSS file directly into an iframe or similar, and style it with CSS and/or XSLT. Instant solution seemingly; but it might require some work to get it working across all browsers.

Alternatively; you could use serverside (PHP, ASP, XSLT, and ) or clientside (Javascript,XSLT [yep its both]) code to parse the RSS and convert it into HTML. Or use something like http://www.rss-to-javascript.com/ http://magpierss.sourceforge.net/ http://www.feedforall.com/free-php-script.htm ( none of these tested; not recommendations, just google results )

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I would think that each sprite/tile should 'have' a location, and 'have' or better yet 'know' an image/model to draw, that way, you can have single instances of each image, and one instance for every individual sprite/tile in game (where some may share a common image). In the sprite/tile's draw function, you could use the values in that location object to determine where to draw the sprite/tile. You don't necessarily need more than one instance of each distinct image/model; but you do need many instances of each sprite/tile and each location... The draw location should certainly be attached to the sprite/tile if not using a grid or other space simplification mechanism..

If you're having the parent class do the 'drawing' rather than calling 'sprite.draw()' for each sprite/tile, you'd need to pass or return it the location of each sprite/tile, yes, and possibly the model/image to draw if that is held in sprite/tile instances. That's not very OO though... Each instance is treated identically, regardless of its compound type..

Ifs? You shouldn't need many if's in the draw routines. 'Cept maybe for error checking.. If you mean ifs to check for collisions, you could do that while drawing, it means you don't have to use two loops over identical indices... it's not particularly good OO practice though, ideally you should have a draw and a run routine.. each one doing a specific, clearly defined thing.. run_and_draw() ?

>> a set location funcion for each individual class which gets …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I'm working with a strange schema of my own invention, it has a requirement that certain structures can only contain other structures; but also that those structures can contain 'filters' that optionally sit between structures-in-structures, i.e, this would be a valid document fragment:

<entity>
  <material name="mat1">
    <texture component="ambient" src="somepng.png"/>
  </material>
  <model src="somemodel.obj"/>
</entity>

as would this:

<entity>
  <material name="mat1">
    <texture component="ambient" src="somepng.png"/>
  </material>
  <dynamic-filter input="level-of-detail">
    <constant-filter-function value="0.5" function="LTE">
      <model src="somemodel_lodetail.obj"/>
    </constant-filter-function>
    <filter-else>
      <model src="somemodel_hidetail.obj"/>
    </filter-else>
  </dynamic-filter>
</entity>

but this would not:

<entity>
  <material name="mat1">
    <texture component="ambient" src="somepng.png"/>
  </material>
<!-- texture is not allowed as a substructure of entity; only can go in material-->
  <texture component="ambient" src="somepng.png"/>
  <model src="somemodel.obj"/>
</entity>

and nor would this:

<entity>
  <material name="mat1">
    <texture component="ambient" src="somepng.png"/>
  </material>
  <dynamic-filter input="level-of-detail">
    <constant-filter-function value="0.5" function="LTE">
<!-- texture is not allowed as a substructure of entity; only can go in material-->
      <texture component="ambient" src="somepng.png"/>
      <model src="somemodel_lodetail.obj"/>
    </constant-filter-function>
    <filter-else>
      <model src="somemodel_hidetail.obj"/>
    </filter-else>
  </dynamic>
</entity>

Now... any complex structure can have any number of filters ( a complex structure doesn't have a src or a type, i.e. it is an xml structure ), and filters inside filters inside filters; but those filters can only 'yield' structures that can go into the parent structure directly.. Since I have more complex structures than 'entity'; and quite a few different filter classes I was stuck with my schema design, either have an #any content within the filter end nodes ( constant-filter-function / filter-else / etc ), which makes the schema about as …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

To be honest; when using grids and cells; you're avoiding OO completely... you'd have a single struct for each cell, with a set of variables; no subclassing in the grid; because it would be unnecessary to do so.. You could though in theory, in that case, you could subclass tile to solid tile and walkable tile; put a virtual function bool canwalk() in the base class.. etc. You could also subclass to 'wall' and have a wall image drawn via a virtual void draw( ) method. Personally, I think OO would suck here. If you DON'T OO, you could load the whole array in a snap, directly from a binary file... College assignments suck.

Better scope for OO is in the parts with the sprites; where you can subclass into players and enemies, and in the items where you subclass into door or token...

MattEvans 473 Veteran Poster Team Colleague Featured Poster

This is quite comprehensive, but it doesn't appear specific to DX or any graphics API: http://www.gamedev.net/reference/articles/article728.asp

Some questions; does the game need to have 3D? You say DirectX, which implies 3D, but it wouldn't have to be 3D to be DirectX.. If not 3D, does DirectX include DirectDraw? From experience a long time ago, it's easier to make tile-based games ( with 2D graphics ) in DirectDraw than DirectX 3D.

Tile based engines are often used in environments where memory ( both in offscreen buffers and on disk ) is limited; traditionally, they have been used for 2D games, but the same principles can be used in 3D; since potential-or-impossible ( broadphase ) collision pruning is very easy when using tiles, and they generally favour games which are restricted to two dimensional movement, which this appears to be.

The tutorial link above uses multiple 2D arrays in the grid. I wouldn't recommend this. Use either a single 2D array of structures or pointers to structures; which store (if 3D) a reference/pointer/index to the model that should be drawn, or if 2D, a reference/pointer/index to the graphical tile to be drawn. Include the solidity flag in that structure. Don't use an obj array; since you only have about 6 'objects' ( enemies, players, tokens, and door ) although, perhaps, put the items ( tokens and door ) into an 'obj' array like that tut suggests; since their positions are only updated during initialization and when they …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

For this game, I'd have a cGrid with arrays (or similar) of cTiles, each with a cImage and some flags indicating solidity. That way, your walls are just tiles with different images and a boolean state solid = true.

I'd subclass cTile to cSprite and cItem. I'd subclass cSprite to cEnemy and cPlayer, put automated control code in the cEnemy ( along with a vector of movement direction ), and I'd put manual control code in the player. Using the grid, you can work out whether the player or enemy is able to move into different positions... i.e, say the grid squares are 20x20 units, take the sprites global position, divide the topleft and bottomright points of the player by 20, chop off the fractional part, and the x and y are x and y indices into the grid, then you can see whether the player can or can't move into a given piece of space.

You can use the same principle to check player collisions with enemy and item sprites, by temporarily assigning sprites to cells in the grid.. in some circumstances it can be faster, however, in this circumstance, I'd say it'd be faster to check physical distances between each sprite every cycle.. if you had a bigger space with more sprites though, it might be faster to assign them into the grid. It will certainly be faster to store the walls into the grid; since the walls don't move. Instead of having to check player …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

It's not a matter of anyone wanting to get around some protective measure if it's possible for that measure to fail without conscious attempts taken to circumvent it, which in this case it is.

My only point is, there's never really a reason why the back button's function _needs_ to be disabled, and I don't think any client would demand that in a spec, since it's a non-function. If you want to hide the toolbar, you want to hide the toolbar and not only disable the back button, and equally, if you actually want a popup, that's a completely different thing to wanting to disable back. If you want to restrict the user's navigation, you're taking away something a user expects to be able to control without any good reason, and if you want to handle some bug in an application that only occurs when back is pressed; there's something wrong in the application.

I wouldn't deny removing the toolbar in a webpage for a client, infact, I might even deliberately popup and remove the toolbar if it seemed appropriate to do so; but if I was working on an application, I would not make any assumptions about the way the user is going to access it. In short, I wouldn't say 'no I wont throw a popup / remove the toolbar', but I would make sure that the application's actual functionality didn't depend on any page being launched in a popup, in the same way as I …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

>> Being Intranet doesn't mean we can assume that all the clients would be using the browser / OS of our choice
>> Intranet applications almost always run in trusted zone so popups won't be a problem unless you specifically plan on disabling them, though it doesn't make any sense as to why someone would disable an intended feature.

Popup settings aren't neccessarily related the trust level of a zone; a theoretical global setting like 'open popups as tabs' could defeat any attempts to hide the backbutton without directly 'disabling' popups, regardless of the zone; if you can't assume a browser/OS of choice, you certainly can't assume a configuration of choice.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

>> Increasing the display area, restricting user navigation, giving the feel of desktop applications,

Fair enough, but one doesn't need to disable back functionality for this, you might want a popup, or just provide fullscreen browsing instructions. The backbutton's actual functionality is irrrelevant here, since the intention is, I guess, to remove the toolbar. You still can't stop the user pressing backspace, or having some registered shortcut that does 'back', or even showing the toolbar; but, I guess in these cases, that wouldn't matter since the reason that the button can't be seen is purely superficial.

>> naive guarding against the infamous back button syndrome when using AJAX etc.

It's a naive and unreliable means for restricting or controlling any part of an underlying application. Anything the user couldn't do without a backbutton, they could do by some other means; trying to hack out the backbutton because it messes with some assumption in the application is addressing the wrong part of the problem.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Wouldn't have to VB, could be C++ et al since the control's an ActiveX, and the same principle applies to all OS that package commonly used components/objects/etc. I was using VB as an example. Could even be done in Java, although not easily.. Alternatively, modify a Firefox version, it's opensource and multiplatform ( maybe write once compile anywhere? no idea ). Intranet implies internal, and companies often control the software on their employees machines.

The popup window method will only work if the browser allows popups, and there's nothing to stop a user re-enabling the toolbar on a popup, or accessing the page without following a path that invokes the popup (i.e direct URL ) still, it's probably a better solution than writing a new browser frontend just to disable 'back'..

I still can't imagine a good reason to disable back. What's the ultimate intention? There will be other means to achieve the same aims ( unless those aims are ultimately to disable back ) without disabling back. That's not to say that those means wouldn't always require any replanning or large modifications; which is why it's a good idea to recognise 'back's' ( and equally 'refresh's' ) existance early on.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

For Intranet applications; it's much easier to control the browser being used to access the page... Open VB6, drop WebBrowser control on form, don't add any buttons that call the control's 'back' event; save; compile; backbutton-neutered IE6. Distribute to everyone onsite.

In any context, including Intranet applications, why should 'back' ever need to be disabled? Just accept it's there, and that it goes back ( to potentially anywhere ); and incorporate that into your plans. Don't overlook it up to the point that it becomes a problem.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

When the link has been clicked, put its' id ( or better, the object itself, or its href, or whatever ) in a global variable.

...
<script type="text/javascript">
var last_link = 0;
function unloading()
{
  if( last_link != 0 ){ ... }
}
function set_last_link( obj )
{
  last_link = obj;
}
</script>
</head>
<body onunload="unloading( );">
....
<a onclick="set_last_link( this ); return true;"/>
...

You might be better off using a javascript-controlled cookie all throughout the site; ie. on every page onload event, read the last URL from the cookie, do whatever you'd intend do when the previously loaded page was unloaded, then write the current URL to the cookie. That way, whenever the user moves between pages, you can find out where they came from. That's gotta be more useful, and flexible, and I can't think of any situation where that would be less suitable than trying to find out where the user is going.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I'll agree, from experience, for most individual tasks, there's not much speed difference between C++ and Java. However; the rigid paradigm inflicted by Java sometimes restricts certain approaches to problems, approaches which, in some cases, could be faster ( or more memory efficient ) than those afforded by sandboxed pure OO... That still stands today.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

His replies were more extreme ( and personal ) than your statements. He is the one being 'overly' anything, by being 'overly childish' in his reprisal. His site looks ok, perhaps he just wanted a superficial review rather than a probing inspection of code. Since the company advertises website design, I think a probing inspection of code is reasonable. I would rate it as being absoultely devoid of any information, but I hate 'advert' sites.

I particularly like the way you've put 'Use of Tables could be supplanted with Divs.' as apposed to something like 'replacing tables with divs will probably be optimum' =P But then, I am a nerd.

In short, you're justified in my eyes; you actually went out of your way to evaluate the site.

I'm going to add 'you belong in the matrix' to my library of heavy insults XD

MattEvans 473 Veteran Poster Team Colleague Featured Poster

In Javascript, you cannot find where the user is going to go next, unless you strictly control the user's movement; something that you can only do within the realms of them navigating using your own controls.

i.e. it's not possible, unless it would suffice to only be notified of such an event if the user goes somewhere using a link directly on your page, in which case, it's easy; just add an onclick handler to all of the links to those other pages. You know where the link is going, because you wrote the link address. If you don't hardcode the link addresses for whatever reason, the link element's href property can be read, and obviously, you could do something more useful than this example with the address: ( i.e. check to see if it is an address for which your session needs to be cleared )

<a href="http://somewhere.com" onclick="alert('Going to: ' + this.href);return true;">Going where?</a>

You cannot, ever, find out if a user is typing in a new URL and is about to hit enter, and browser forwards/backwards actions can't be reliably monitored, nor averted.

At the server, you can find out where the user has been going ( within your site ) by looking at where the user has come from ( REQUEST_URI in the HTTP header ). I don't believe that this is possible in Javascript.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

>>I guess this is one of those choices the OP would have to make based on his requirements.

Pretty much.

>> But in return of all this you get flexibility, the ability to change the logic without sifting through 6000 lines of your markup. Plus the load times would be less than or at the most equal to the time taken to set onclick on 6000 links by hardcoding them.

I would debate that using JS to generate onclick handlers could save much on download time and configurabilty unless the functions and their parameters can be derived automatically with a minimum of link-specific information hardcoded anywhere in either the JS or HTML. i.e, for extreme example cases:

( hardcoded )

<a href="#" onclick="return sf('data01')"/>

= association between a's and click handlers is hardest, function name can't be changed easily, most flexible; because different functions can be called.

( changing 'c' classed 'a' elements to call an onclick function with a parameter equal to the a's id )

<a href="#" class="c" id="data01"/>

=association between a's and click handlers is medium, function name can be changed in JS, but id's have to be changed in HTML and function name can't be changed ( unless more than one class is used ), there is a noteable decrease in HTML size, but at a runtime cost compared to hardcoding. Small JS file also. Might be optimum, might not. Especially when considering that you can't legally put all …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Alternatively, get rid of the tables and use DIVS+CSS.
You will probably end up using 1/4th less code, and find it much much easier to see problems and make alterations.

To rephrase that to be accurate rather than emotive: you might end up using a 1/4 less code, you might find it easier to see certain problems, and you might find it is easier to make alterations. Equally, you might end up using the same amount or more code, running into problems that are very, very difficult to see, and finding it more difficult to make controlled alterations. There's no 'probably' about it in any general case.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

If all the functions are equal with equal parameters, or equal ( or derivable ) functions where the parameters can be easily derived programatically per link, i.e. via setting some dummy property on the link and using it to generate or lookup the function parameters. Otherwise I can invisage an equally huge JS file... Plus, it would take some noticable, although not restrictive, post-load time to dynamically set the onload property for 6000 links..

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Ah yep, I get it. Hm.. thinking about it though.. Fungus1487; you could save a bit of transmission bandwidth with 6000 links involved, if you onclick="return some_function()" and make sure some_function always returns false.
In uncompressed 8bit ASCII; the dif between:

return some_function() 
some_function();return false

is 6 characters per link, meaning you'll potentially save {about} 36KB on 6000 links of the same type.. =P

Smells understandable in this circumstance.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

An Internet SMS gateway is just a connection between the TCP/IP network and the GSM network. If you access it using an email to a mobile service provider, your gateway is on the machine that collects the email and forwards it onto the SMS user via the GSM network. If you access it by connecting to some high-load multiprotocol server that does the same thing, your gateway is there.

Google can afford as many high-load servers as they need for any protocol they desire. You're probably better off hiring usage on a popular public SMS gateway with accessible connections to all parts of the network, since making your own connections to different service provider's 'parts' of the GSM network isn't likely to be easy, and service providers giving free access to an automated email-to-SMS service probably restrict transmissions to within their own part of the network (i.e. to their own customers ). O2 in the UK used to ( perhaps still? ) provided a web-based service that delivered to all UK networks, but it it was on a monthly credit allowance basis. It was/is a frontend to an HTTP-over-TCP/IP to SMS-over-GSM gateway, but it isn't anything special. http://en.wikipedia.org/wiki/Gateway_(telecommunications))

It's not done only in Javascript by any means. The 'number' is submited maybe via HTTP forms, or maybe via Javascript AJAX to the Google server, which subsequently forwards the message into the GSM network via a gateway, where the network provider CAN be derived from the number …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Placing it directly in the anchor element feels better.

If you mean directly in the href attribute of an anchor element; href isn't an event handler.. so that smells worse to me.

I guess the event chain for a user click on an <a> element is something like: ( ignoring mousedown, mouseup, mouseover, and mouseout events )

if( onclick( ) ){ if (href ){ [navigate to href] } }
MattEvans 473 Veteran Poster Team Colleague Featured Poster

User input is not handled ( or ever mentioned ) in the OpenGL specification. It is a graphics spec not an input spec.

There are libs that provide this functionality for OGL apps in a multiplatform way, i.e. glut and SDL... but keyboard and mouse handling is otherwise platform dependant. You should probably use one of these libs ( the windows API will also provide this functionality, but it's then platform dependant ).

So, more important than using 'OpenGL', what OS are you using, what development language are you using, and what libs would you be prepared to use aswell as OGL.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

i have been using this practice for years but have come across a problem. using '#' will refresh the view of the page (thus if having scrolled miles down a page, resulting in a lovely jerk back to the top)

Try: <a href="#" onclick="some_function( );[B]return false;[/B]" /> I haven't tested it, but, it's advocated here: http://blog.reindel.com/2006/08/11/a-hrefjavascriptvoid0-avoid-the-void/, and it makes sense in theory.

How about ditching anchor tag all-together?
...

Use css behaviours instead.

This is ideal in theory, but older browsers ( i.e. IE6 ) don't support the :hover psuedoclass for any element except <a>, and the :visited psuedoclass _certainly_ won't work in this context in any browser. However, new browsers seem to be supporting :hover on any element, which is a good thing.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

The URL of the document that the browser is currently viewing is in the property window.location.href

MattEvans 473 Veteran Poster Team Colleague Featured Poster

because you have made the input button after the head tag you can not use the script in the head so you have to write the code after the input button , another problem you had you have to use disabled instead of disable

Or use the body onload handler as sos suggested.. It makes for a more manageable project if you use onload to call one onload function that does all one-time-only functions, rather than putting bits of script inbetween html elements..

To srinivaskota, if you have some condition that must be met to enable the button; and the condition is usually not yet met when the page is first accessed ( or refreshed ), i.e. the button should only become enabled as the result of some javascript code; set the button as disabled in the HTML, i.e.

<button disabled="true" >Button Text</button>

Then, when the condition is met, set the element's disabled property to false. You'll still probably need an onload handler to check if the condition is met, if it's some kind of persistant condition.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

It blued out for me again, see attached. My post wasn't showing blue until you started it all over again =P.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

In Opera, I only see a single line ( and single line number ) in my posted codeblock..

But, there's a superfluous <li> in the HTML close to the screwy '</span</span>' part.. So, there should really be another line number shown.

In Firefox 2, I see the same as MidiMagic, a pair of line numbers, with one over the other; but ONLY in this (unfinished quote) case and normally they are absolutely fine.

The browsers are dealing with the bad bit of data differently, which is unsuprising really, since 'correct' behaviour isn't defined. Opera hides the next <li> and spills blue from the unclosed quote to the end of the Daniweb page, Firefox squashes the next <li> and continues as per usual.

I thought there'd be quite a simple explanation, like the parser starting a blue span and not closing it.. that's what it looks like in Opera. Personally, I wouldn't rank this problem as 'high priority' if you're having trouble nailing it down.. It doesn't seem to be exploitable.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Use the indexOf() method of the string object:

var string_a = "ABCDEF";
var string_b = "DEF";
var iof_b = string_a.indexOf( string_b );
if( iof_b == -1 )
{
  alert( "Cannot find the string " + string_b + " in " + string_a );
}
else
{
  alert( "Found the string " + string_b + " in " + string_a + " at character index " + iof_b );
}
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Ah... it's not doing it on Firefox, only Opera.. strange :|

Hm.. the code for this page looks wierd here though:

<div class="de1">[B]<span class="st0"</span>[/B]</div></li></ol></pre>

and here:

&lt;a</span> <span class="kw3">href</span>=<span class="st0">&quot;</span></div></li><li class="li1"><div class="de1"><span class="st0">[B]</span</span>[/B]</div

Assuming that's autogenerated by the syntax highlighter; I would assert that that's where it goes wrong, and that Opera and FF have different ways of dealing with the glitch.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

On original topic; what are your thoughts on an HTML+Javascript syntax highlighting mode?

MattEvans 473 Veteran Poster Team Colleague Featured Poster

If you open an HTML element attribute and forget to close it within an HTML code block; then the 'blue' style continues into the rest of the post, and, if your thread view is linear > oldest first ( mine is usually linear > newest first ), the blue spreads into other peoples posts aswell; and then it goes on into the rest of the daniweb interface. I think it's the same with C++ strings:

std::string hello( "hi
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Well. it seems firefox truely sucks, it allows this:

<html>
<head></head>
<body onunload="while( true ){ alert( 'hi' ); }">
</body>
</html>

which executes when the user closes the browser, or navigates away from the page. Opera doesn't, because Opera's a good browser, and even if it did, one could break out of it quickly.

That only works to 'delay' the browser closing because alert is a blocking function; it doesn't return until the user clicks ok. if you could find another blocking function that isn't so insidious, you could run that.. or even 'while' loop repeatadly. It'll only work for firefox ( and likely IE to be honest ), and it'll likely annoy your users... but hey.. also, the browser window closes fully in FF2, and an alert just pops up until the program's terminated manually... so, you can't 'see' the page behind atall, but you can execute any code you desire to.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Why on earth would you want to do something so outright annoying? If I click close, I want closed.

No, there isn't an easy away to do this. You can catch the body "onunload" javascript event, and run code there; but it doesn't mean the same thing in different browsers. Regardless, you cannot 'cancel' or 'delay' the closing of the page or browser.*

Imagine the user accessing a page as them opening and closing their browser simultaneuously; that's effectively how HTTP works. You can't make any assumptions about what the user ( or browser ) does once they have downloaded your page, and certainly don't view them as being 'on' your page; they're just looking at a copy of it.


EDIT: * just to add, it's not possible in most ( all modern ? ) browsers, for reasonable security reasons, not because it would be technically difficult.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

As title; unless there's already a way:

<html>
<head>
<script type="text/javascript">
function myfunction( )
{
  alert( "Hello, World!");
}
</script>
</head>
<body>
<p>Some HTML code</p>
<img onclick="myfunction( );" src="some_image.gif"/>
</body>
</html>
<html>
<head>
<script type="text/javascript">
function myfunction( )
{
  alert( "Hello, World!");
}
</script>
</head>
<body>
<p>Some HTML code</p>
<img onclick="myfunction( );" src="some_image.gif"/>
</body>
</html>

Not a major problem, I know, This example doesn't show the problem well, but when posting loads of HTML, with loads of Javascript in the same block; I find myself having to 'pick' between one or other inperfect formats.. HTML+Javascript could highlight both..

On another note.. there's a style leak in the HTML formatter:

<a href="

My signature will be blue! That's a minor, almost insignificant, problem though.

EDIT: Ah, it seems to spill further than my signature..!

MattEvans 473 Veteran Poster Team Colleague Featured Poster

And here's another way:

<html>
<head></head>
<body > <!-- onblur="self.close()"-->

<div style="text-align: center;">
<p>If you like this site, you will love these<br />
wonderful books. Click <a href="http://www.amazon.com">here</a>
to buy.</p>

<script type="text/javascript">

var i = 0;

var imageArray = new Array();

//Create each element of the array as a unique object with a src and href parameter. This is quick and dirty; you could create an 
//object 'class' for this.. but.. perhaps it's overkill. You could also use a pair of arrays with matching subscripts.

var img0 = new Object( );

img0.src = "http://ec1.images-amazon.com/images/I/51EPPN3B2WL._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg";
img0.href = "http://www.amazon.com/Cult-Mac-Paperback-Leander-Kahney/dp/1593271220/ref=pd_sim_b_4_img/102-1309812-8345769?ie=UTF8&qid=1188507280&sr=8-3";

var img1 = new Object( );

img1.src = "http://ec1.images-amazon.com/images/I/51209PBGM8L._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg";
img1.href = "http://www.amazon.com/Apple-Confidential-2-0-Definitive-Colorful/dp/1593270100/ref=pd_sim_b_1/102-1309812-8345769?ie=UTF8&qid=1188507280&sr=8-3";

var img2 = new Object( );

img2.src = "http://ec1.images-amazon.com/images/I/31PVMJMNFBL._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg";
img2.href = "http://www.amazon.com/Insanely-Great-Macintosh-Computer-Everything/dp/0140291776/ref=pd_sim_b_4/102-1309812-8345769?ie=UTF8&qid=1188507280&sr=8-3";

var img3 = new Object( );

img3.src = "http://g-ec2.images-amazon.com/images/I/512AG45B3GL._AA240_.jpg";
img3.href = "http://www.amazon.com/Revolution-Valley-Insanely-Great-Story/dp/0596007191/ref=pd_bbs_3/102-1309812-8345769?ie=UTF8&amp;s=books&amp;qid=1";

//Put all of those objects into the array.

imageArray[ 0 ] = img0;
imageArray[ 1 ] = img1;
imageArray[ 2 ] = img2;
imageArray[ 3 ] = img3;

function rotateImage()
{

  if (i >= imageArray.length)
  {
    i = 0;
  }

  var img_element = document.images[ "pic" ];
  img_element.src = imageArray[ i ].src;

  i++;

  setTimeout("rotateImage()", 2000);

}

//When image is clicked, move browser to the href corresponding to the current image
function visit_current( )
{
  //Note i-1; because i is incremented after every image swap. Thus must check for 0 condition
  if( i == 0 )
  {
    window.location = imageArray[ …
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Here's one way to do it:

<html>
<head></head>
<body > <!-- onblur="self.close()"-->

<div style="text-align: center;">
<p>If you like this site, you will love these<br />
wonderful books. Click <a href="http://www.amazon.com">here</a>
to buy.</p>

<script type="text/javascript">

var i = 0;

var imageArray = new Array();

//Create each element of the array as a unique object with a src and href parameter. This is quick and dirty; you could create an 
//object 'class' for this.. but.. perhaps it's overkill. You could also use a pair of arrays with matching subscripts.

var img0 = new Object( );

img0.src = "http://ec1.images-amazon.com/images/I/51EPPN3B2WL._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg";
img0.href = "http://www.amazon.com/Cult-Mac-Paperback-Leander-Kahney/dp/1593271220/ref=pd_sim_b_4_img/102-1309812-8345769?ie=UTF8&qid=1188507280&sr=8-3";

var img1 = new Object( );

img1.src = "http://ec1.images-amazon.com/images/I/51209PBGM8L._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg";
img1.href = "http://www.amazon.com/Apple-Confidential-2-0-Definitive-Colorful/dp/1593270100/ref=pd_sim_b_1/102-1309812-8345769?ie=UTF8&qid=1188507280&sr=8-3";

var img2 = new Object( );

img2.src = "http://ec1.images-amazon.com/images/I/31PVMJMNFBL._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg";
img2.href = "http://www.amazon.com/Insanely-Great-Macintosh-Computer-Everything/dp/0140291776/ref=pd_sim_b_4/102-1309812-8345769?ie=UTF8&qid=1188507280&sr=8-3";

var img3 = new Object( );

img3.src = "http://g-ec2.images-amazon.com/images/I/512AG45B3GL._AA240_.jpg";
img3.href = "http://www.amazon.com/Revolution-Valley-Insanely-Great-Story/dp/0596007191/ref=pd_bbs_3/102-1309812-8345769?ie=UTF8&amp;s=books&amp;qid=1";

//Put all of those objects into the array.

imageArray[ 0 ] = img0;
imageArray[ 1 ] = img1;
imageArray[ 2 ] = img2;
imageArray[ 3 ] = img3;

function rotateImage()
{

  if (i >= imageArray.length)
  {
    i = 0;
  }

  var img_element = document.images["pic"];
  var a_element = img_element.parentNode;

  img_element.src = imageArray[i].src;
  a_element.href = imageArray[i].href;

  i++;

  setTimeout("rotateImage()", 2000);

}

</script>

<p>
<a href="http://www.amazon.com/Cult-Mac-Paperback-Leander-Kahney/dp/1593271220/ref=pd_sim_b_4_img/102-1309812-8345769?ie=UTF8&amp;qid=1188507280&amp;sr=8-3">
<img src="http://ec1.images-amazon.com/images/I/51EPPN3B2WL._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg" 
id="pic" 
name="pic" 
alt="Pictures of Classic Macintosh" />
</a>
</p>

<script type="text/javascript">
rotateImage();
</script>

</div>

</body>

</html>
MattEvans 473 Veteran Poster Team Colleague Featured Poster

You need access to an SMS gateway. You can hire this access from a number of companies, usually they'll charge a subscription or usage fee. I can't recommend any, but that's what you need; heres some examples, from the first page of google results for SMS gateway: http://www.clickatell.com/ http://www.ozeki.hu/** , and this page has some comparisons : http://www.developershome.com/sms/smsGatewayProvComp.asp . This assumes that your target audience is in a country that uses SMS for mobile text messages..

The code you use would depend on the gateway service, they'll likely have their own access/security protocol and provide specific developer instructions.

** hm, I had a look at this one again, it's not a rented service, it lets you use your phone/sim/contract as an SMS server; which is a different approach; probably not useful for high volumes of texts, but perhaps worth looking at.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

you can use it to control the display of anything, it hides the element it is applied to and all elements that are descendants of that element.

if you were hiding another element, you'd have to use the getElementById( ) function or similar in the body onload event to get hold of the element to re-display.

But, there is only an onload event on the html>body element. There isn't one for every element on the page. The body onload is raised ( in theory ) when everything in the document has been loaded.. exactly what that means isn't particularly well defined.

if you place a script element some way down the code in a page, it's pretty safe to assume that the script in it will be executed after all of the document above that point has been loaded. ( but loaded is not the same as rendered ). i.e, in the same vein as the previous example:

<html>
<head>
</head>
<body>
<img id="img1" style="display:none;" src="some_huge_image.bmp"/>
<script type="text/javascript">
document.getElementById( 'img1').style.display='';
</script>
</body>
</html>

In this case, it's pretty much certain that the script will execute when the <img/> tag has been interpretted and is ready to be rendered, or perhaps even has been rendered. But the image will not neccessarily have been sourced ( i.e. the actual image data might still be being downloaded when the script runs ), because most browsers push that task to 'after' the page has been rendered.

Whats the 'type' …

MattEvans 473 Veteran Poster Team Colleague Featured Poster

strictly, you can't. browsers seem to have their own rendering order, and this can change depending on the document type of the page being rendered.

you can 'hide' a page's content until the page raises the 'onload' event, which should be done when the page has been fully 'loaded' into the browser, at this point, it should be possible for it to be rendered instantaneously..

<html>
<head>
</head>
<body style="display:none;" onload="this.style.display='';">
<img src="some_huge_image.bmp"/>
</body>
</html>

This has the disadvantage that, the user sees nothing until the page has loaded..

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Internet Explorer allows some JavaScript statements to work correctly without semicolons, but other browsers do not. So IE cheats. Don't write your code to rely on IE quirks.

IE is correct; according to the 'standard' semicolons after javascript statements are optional. Or, as I just read; 'automatically inserted by the parser when it encounters newlines'. Read the ECMAScript standard document if you like.. javascript is approximately equal to ( and syntatically identical to ) ECMAscript. I'm not sure which ecmascript version corresponds to which JS version, but the semicolon thing has been around since before I saw any javascript. If other browsers aren't allowing this, they're not using conformant ECMAscript parsers.

http://www.ecma-international.org/publications/standards/Ecma-262.htm

it's a word doc, do a search in it for 'automatic semicolon insertion'. saying that though; I'd personally recommend a real semicolon after every statement. ( in javascript and english. )

perhaps you're getting confused about java / javascript yourself there MidiMagic :P ... but, the OP did insist on repeatadly 'saying' java even after correction... the original code is html + javascript + asp with vbscript, without a hint of java. and it's way too long for me to read more than half of it.

who had the java.* name first?

MattEvans 473 Veteran Poster Team Colleague Featured Poster

...Perl kicks PHP's scrawny unmanageable a$$... But both are inperfect for different reasons.

C++ is rule for web applications; not easy to use admitadly, it doesn't natively have the text manipulation features of Perl, nor the huge library of builtin nonsensically named functions as PHP, but if you're gonna write in a language that gets more and more C++-like with every release ( i.e. PHP ), you may aswell write in a language that can be compiled.. Zend is written in C++, and adds effecively nothing to the language apart from an additional layer of interpretation, and the aforementioned set of builtin functions; which are afforded ( better ! ) by third-party C++ libraries. At least Perl doesn't look like, or try to emulate weakly typed C++.

If you have a choice, write in C++ with XML libraries and a database library; or Java, which has both in the standard library. All the 'mixing HTML with server app code' functionality as afforded by PHP, ASP, and also Perl and others, is overated at best, and a manageability nightmare at worst.

Just my opinion, of course..

MattEvans 473 Veteran Poster Team Colleague Featured Poster

You can't read the data you have in your C# server app from the javascript code running in the client. A common way to 'get' data from server apps to javascript is to write the data values directly into the generated javascript code in a response... I don't know any C#, but I'll pretend C# is C++:

( in part where outputing the page data )

std::vector < std::string > the_cpp_array;
some_function_to_populate_the_array( the_cpp_array );
std::cout << "<script type='text/javascript'>\n";
std::cout << "var the_js_array = new Array( ); \n";
for( int i = 0; i < the_cpp_array.size( ); i++ )
{
  std::cout << "the_js_array[" << i << "] = '" << the_cpp_array[i] << "';\n";
}
std::cout << "</script>";

thus, if 'the_cpp_array' was filled like: { 'hi', 'I', 'am', 'an', 'array' }
then the generated javascript would be:

<script type="text/javascript">
var the_js_array = new Array( );
the_js_array[0]='hi';
the_js_array[1]='i';
the_js_array[2]='am';
the_js_array[3]='an';
the_js_array[4]='array';
</script>

That code could then run on the client, and the javascript could access the data. That assumes that you're generating the page content from within C#.. Erm.. sorry if you can't translate that from C++, I can't translate it to C#.

You might get a more useful answer from the C# forum.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

If you leave the index.html page out of a folder, on some servers, with some configurations, it does that for you.

Admitadly, you might not want the default index page (it's ugly ), or your server might not support it, or it might be disabled.

The most controllable way would be to write a little server-side script to do it. What scripting languages do you have access to on the server? What's the server OS aswell? And the server application?

If you have a Linux+Apache server ( or some other combinations, include Windows+IIS with the right settings ), and you can use Perl; something as simple as this would work:

#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "<html><head><title>Directory Index</title></head><body>\n";
print "<h1>All of the files in this folder:</h1>\n";
foreach( glob( "*.*" ) )
{
	print "<a href=\"$_\">$_</a><br/>\n";
}
print "</body></html>\n";

Save as "index.pl", upload it, and give it execute permission ( linux chmod 755 ).. You'd also need to configure the server to treat index.pl files as directory indexes. Honestly, without knowing server OS and server application though.. I don't think I'm being that helpful.

If you only have access to PHP.. er, I can't bring myself to write in a language that ugly, but, it's equally easy.

This isn't an HTML/CSS question... but don't worry, its not a specific server lang question either.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Do you have a <!DOCTYPE tag at the beggining of your page? if not, why not? =P See: http://www.w3schools.com/tags/tag_doctype.asp; and http://hsivonen.iki.fi/doctype/.

If you do, which one? text-align: center; should cascade from table into table cells.. if it doesn't try setting it explicitly on the table cell : <td style="text-align:center;", and if that STILL doesn't work; try this on the img tag:
<img style="display:block;margin-left:auto;margin-right:auto;"

However; that does work for me on Firefox version 2.0.0.6. I get the image centered, and it stays centered if I remove the <center> tag ( because of the align:center; on the table )...

What is the content of the class 'style357'? Can you post a screenshot of it NOT working, I can't seem to get it to display wrongly, but I'm not entirely sure of what it should look like..

MattEvans 473 Veteran Poster Team Colleague Featured Poster

try something like this:

object.filters.alpha.opacity+=direction*delta;
object.style.MozOpacity+=direction*delta;

+ other additions where neccessary; [object].style.MozOpacity is the JS property though.

Also, for style attributes it's not usually advisable to work incrementally (i.e. += x )... it will probably be ok in this case, to be honest, but I try and stick to creating a global variable somewhere, incrementing that, and then setting the style attribute directly...

MattEvans 473 Veteran Poster Team Colleague Featured Poster

Erm.. not using javascript. It's not a good way to adequately password protect pages. The best you can do with javascript is:

- hide everything but the password form on the page (wrap everything in an html element, set display:none; or visibility:hidden; in css) unless the user enters the correct password (then set everything visible, using display:; or visibility:visible; respectively). unfortunately, everything on the page can be seen using view > source.
- have the page redirect when the user enters the correct password ( as you're doing here ); again, anyone can look at the source, and find out the URL of the restricted page.
- the best javascript 'password protection' i've seen did this: have a page with a password form; when the user enters anything in the password field; the script redirects to a folder with the name of the correct password; the basic principle is, that it's difficult for the average user to know where the folders on a webserver are, unless you give some hint ( links, common folder names, etc ). every incorrect guess will redirect to some unmapped location on your server; not ideal, but it restricts access. the bad point here, is that any user watching an 'admin' can see what the password-named folder is.. but, it's the best javascript password restriction method that I can imagine. You could take it a step further, and transform the password entered by some text/ascii math function before redirecting, but, the script …

iamthwee commented: correct! +11
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Are you getting a compiler error or a runtime error? I get a compiler error if I try to build that:

if(SDL_SetColorKey(bmp, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(bmp->format, 0, 0 ,0)) == -1)
//<----THERE SHOULD BE AN OPENING BRACE
            fprintf(stderr, "Warning: colorkey will not be used, reason: %s\n", SDL_GetError());
            } //<---- OR NO CLOSING BRACE

But, that might just be because you've pasted the body of a function/block and missed the opening brace from the start of the function/block....

I don't get any runtime error once I successfully compile; if you're getting a runtime error, try taking out the SDL_MapRGB(bmp->format, 0, 0 ,0) and replacing it with 0. Based on literature here: http://docs.mandragor.org/files/Common_libs_documentation/SDL/SDL_Documentation_project_en/sdlpixelformat.html, I reckon it's a safe bet that RGB 0, 0, 0 will usually be 'color key' 0, UNLESS you're using a palleted bitmap.. Try it, see if it works and if you get the right effect... Also, check if the bitmap was successfully loaded before trying to access bitmap->format. I got a segfault the first time I ran that, because I didn't have a pong.bmp file.. Do a check like:

SDL_Surface* bmp = SDL_LoadBMP("pong.bmp");
if( bmp == NULL )
{
  cerr << "Bitmap didn't load: " << SDL_GetError(); 
  return 387;
}
MattEvans 473 Veteran Poster Team Colleague Featured Poster

Lol. I didn't mean to offend either.

The problems with making a browser that updated on every W3C change are massssive. The W3C typically leave 'implementation details unspecified', so there's always a one-to-many mapping between a standard and a correct implementation of that standard. Unless the W3C made a standard for the implementation of their standards; it wouldn't work. It wouldn't be hard to make a browser that correctly implemented the necessary browser standards as they stand today. To be honest, IE7, and the latest versions of Opera and Firefox are pretty close; at least they try to implement the present standards, which is a good thing, and the best that can be asked really; that, and frequent ( allbeit manually written and potentially bug-ridden ) update releases.

MattEvans 473 Veteran Poster Team Colleague Featured Poster

I would. That way, a nice browser; Firefox, Opera etc, will prompt to open ( in the default .doc application ) or save the file, and IE may or may not open the file in the browser window depending on preferences... File>Print and File>Save as should certainly still work, even in an IE mixed with Word window...

MattEvans 473 Veteran Poster Team Colleague Featured Poster

er... who's your target audience. will they be using IE5? you ( should ) know your target audience better than anyone.

i wouldn't design for IE5. It's not up-to-date with modern standards, and it'll pull your work back into the dark ages. That said, it doesn't hurt to check code in IE5; but don't design for IE5.. does that make sense?

Totally W3C compliant is an ongoing thing, the W3C make new specs every now and again, no browser version will ever meet all of those specs, and even less likely; all specs they ever intend to develop. It would be like being 'totally ISO compliant' - do you know how many ISO standards there are, and how irrelevant it is for most applications to comply with most of the standards?

What the hell is web 2.0? Is it a standard? No. It's a buzzword. web 2.0 will become web 11.0 when people get bored of claiming to be web 10.0.

Linux OS replaced Microsoft Windows on my computer, that's where it's important to me. I use Mandriva 2007. How the OS looks is of minimal importance to me honestly... I use this one because was easy for me to start using the old version ( Mandrake 10.1 ), perhaps because it felt a little like windows. I can put my 'Mandriva' button ( start button ) anywhere, apps should be color coordinated to the taskbar not the other way around, my OS makes me go …