Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Just a word of warning by the way, unbinding events like you are doing can cause some unexpected results. As you unbind() the event, this will unbind everything. If you have multiple selectors pointing to the same element, that both bind a click event, then using unbind() will remove them both. Just letting you know to save yourself some possible headaches later. Personally I would use a logical approach to this, instead of removing the event. Perhaps set a property within the object when it's clickable. For example: $('#image1').click(function() { if (this.clickable || typeof(this.clickable) == 'undefined') { alert('Show for the first time.'); this.clickable = false; } }); $('#image2').click(function() { alert('Now allow to click one more time on first.'); $('#image1')[0].clickable = true; });
  2. You're not binding anything to the click event. As you're using an anonymous function, when it's unbound it no longer exists. What you should do is bind the click event to a named function, so it's easy to re-bind later: http://jsfiddle.net/kBMfL/ Note the added unbind() within the re-bind, to prevent clicking the blue image multiple times binding the handler multiple times.
  3. You're approaching the structure of your tables wrong. Instead of an "unlimited number of columns" - which would be a maintenance nightmare - you should be utilizing rows, which is really the power behind relational tables. Although I don't at all understand the relationship between the original code snippet you posted and the above description? Also we can't give you some magic code to do what you want, because it's heavily dependant on what you're trying to achieve. The description above is still too vague to suggest the best way of approaching it.
  4. The entities have been double encoded by the look of it. First it was: Beethoven’s Trinklied No. 282 Now it's: "Beethoven’s Trinklied No. 282"; So a second time through html_entity_decode() should produce: Beethoven’s Trinklied No. 282 I strongly urge you to investigate why the value is double encoded though, instead of just passing it through several times.
  5. As I said, the HTML may be stored incorrectly in the actual file itself. Which editor are you using?
  6. It's a character set issue. You should use UTF-8 to ensure all (or at least most) characters are rendered correctly. It could either be in the file itself - most editors have an option to convert to UTF-8 - or the browser rendering it. Add the following META tag and see if it fixes the issue: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  7. SimpleXML doesn't work well on HTML files, especially if they have javascript/css written into the file. Quite right. The DOM then: $html = '<!DOCTYPE html> <html> <head> <title>This is the title</title> <meta name="keywords" content="this is a self-closing tag" /> <meta name="description" content="this is not a self-closing tag"> <meta name=author content=idiot> <script> window.onload = function() { alert(\'here\\\'s some JavaScript..\'); } </script> </head> <body> </body> </html>'; $dom = new DOMDocument(); $dom->loadHTML($html); foreach ($dom->getElementsByTagName('meta') as $meta) { echo 'Meta ' . $meta->getAttribute('name') . ' = ' . $meta->getAttribute('content') . '<br />'; } Works even with some pretty badly written HTML.
  8. On successfully sending the message, I would redirect back to the same page with a simple flag in the URL: if ($message_sent) { header('Location: index.php?sent'); exit; } Then when displaying the contact form: <?php if (isset($_GET['sent'])): ?> <p class="success">Thank you, your message has been sent.</p> <?php endif; ?> <!-- Contact form here.. -->
  9. Those are HTML entities. Flash is not HTML, so you need to decode them. You could pass the string through html_entity_decode: amzn_wdgt.title='<?php echo html_entity_decode($keyword); ?>'; Ideally though you should find where the string is originally converted to entities (either with htmlentities or htmlspecialchars) and remove the escaping there. Also, removing the entity conversion would mean that the single quote would now break the JS syntax, so I would pass the string through json_encode without the surrounding quotes: amzn_wdgt.title=<?php echo json_encode($keyword); ?>; That will result in escaped notation that JS can understand. Don't forget to remove the HTML entity escaping though.
  10. Support for the ":nth-child" CSS pseudo-selector isn't quite dependable just yet by the way; <= IE8 has no support at all. You can remedy that with jQuery if you wish though.
  11. With jQuery you should be able to use something like: $(document).scrollTop($(document).height());
  12. Oh I see. Well you realise using SimpleXML you could probably parse out that information pretty easily right? Even a simple regex would do the trick.
  13. Not following you here? Surely if you know the URL to get the tags, you can construct a cURL request instead?
  14. There's a pseudo-selector you can use to check if an element is currently in animation: if ($('#element').is(':animated')) { // ... }
  15. Just to add, response headers are a part of the HTTP foundation. They're the least-cumbersome and most supported way of handling redirection, and should ideally be all you use for it. There's nothing stopping you redirecting back to the same page you're on, which incidentally has the added benefit of overwriting the previous request, preventing "POST-refreshes" (the browser dialogue that pops up when you go back, asking if you want to re-submit the POST data). On the target page you can then simply check the type of user (admin or regular), and display the appropriate output.
  16. I would advise against what you're trying to do. After the form has been submitted and the page has finished loading, I don't see any benefit in refreshing the page? Keep requests to a minimum. The way I would do it would be to just display a little confirmation message above the form, notifying the user their message was sent successfully. That's it. Having said that, if you really want to do it, I would add a callback event to the countdown. Looks like you can use "onExpiry", assuming I'm looking at the right countdown plug-in: $(document).ready(function() { $('#countdown').countdown({ seconds: 10, onExpiry: function() { window.location.reload(); } }) });
  17. I don't fully understand what you're trying to do. Why do you want to reload the page after a form is submitted? Also why is there a count down?
  18. You can just use the window.location.reload() method. If you do that, the browser *should* automatically jump back to the same part of the page after the reload.
  19. The regex provided in playful's post doesn't actually validate against the specific data requirements you mentioned. Replace it with: /^[a-z0-9\.-]|[a-z0-9]{16}|[1-3]$/
  20. OWASP is a good all round resource. There's also a very helpful PHP security tutorial on this site.
  21. What about PHP?
  22. .. Or if you really want to have a fun day, you can get into automated regression testing.
  23. You're looking for a "WYSIWYG" editor. There's a few popular ones to choose from: http://en.wikipedia.org/wiki/HTML_editor#Online_editors I would advise against TinyMCE - from what I've seen it's not particularly well written.
  24. Exactly, that's a very specific situation. Then again that isn't going to be much of a difference relative to the full file size. Plus you can minify it, and as I mentioned gzip makes short work of ASCII text. I really don't see the point in getting so hung up on white-space, there's bigger fish to fry!
×
×
  • 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.