I need to use XHTML strict
I need to ensure my site works with no javascript.
I need to open a new help window from my own application. Of course I wanted to use target="_blank" when no javascript detected but this is not XHTML strict.
Are there any alternatives?
You have to use javascript in this case. If you don't want to use javascript, and still have valid markup, don't use XHTML Strict as your doctype.
document.getElementById("mylink").target = "_blank";
Or you can attach a click-event to the link that opens the address up in a new window. Either way, javascript is your solution if you want valid markup.
You can only do this by:
Use Transitional doctype
or use JavaScript
Don't force new windows on visitors
This is the easy way:
link
<a href="http://www.google.com" onclick="this.target= '_blank';return true;" >Google</a>
Actually, there may be a way to do this without javascript. You can write a custom DTD as described here.
Add a target attribute to your customization and it will validate. I just came up with this idea and I'm not sure if I'm missing any drawbacks.
Try to use this:
http://www.webaddress.com' target='_blank'
as the address.
Related
So looking around to see if I could find the answer before posting but can't find any or I'm overlooking it but I tried validating an XHTML 1.0 Strict document. In the HTML code I have:
<span id="return">RETURN</span>
So, when I put the document through the validator, it says " there is no attribute "target"" and it gives an explanation of ". . . . you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead . . ." Though I'm willing to change the document type to "Transitional," but I'm more intrigued with the latter and wish to know how i can achieve this . . .
Validator instructions are quite clear I think. Opening in a new window is not possible with pure xhtml strict, only in xhtml transitional.
You could use JavaScript instead.
The other possibility mentioned aims for this CSS3 property i guess, which doesn't seem to work yet and is just some JavaScript replacement anyways.
But imho if you use CSS3 you don't need xhtml strict either, because a browser that can handle CSS3 is more than likely to also handle newer doctypes like html5.
/edit: Note that the thing with "marginheight" is just an example from the standard-errormessage which appears for several different problems.
Use XHTML5, you get the benefit of HTML5 elements along with the benefits of using the XML parser so just use the <!DOCTYPE html> as Mr Lister mentioned in his comment. My website / platform uses XHTML5 so if you're curious how the syntax should look either ask and/or visit the link in my profile. :-)
I have been using CakePHP for a while and recently needed to send emails from an app. Unfortunately I can not figure out a way to tell CakePHP to include the css directly in the document as an internal style sheet instead of a link. I know people think that is a bad idea, but my app is only sending emails to our company so I'm not worried too much about someone's email client messing it up. If I just include the link it doesn't work since the reference is wrong, although if I could make the link an absolute link (http://myserver/css/myfile.css instead of /css/myfile.css) that would be a 2nd best alternative since they would have access to my server.
If there isn't a way to do it in Cake, is there a quick way to just use PHP to read the contents of the file and dump it in the view? I guess I could do that from the controller, sounds like a bad hack though.
Any ideas would be appreciated, thanks
You could use readfile() to print the file content directly in your view.
Or you could $this->Html->url('css/yourcss.css', true) to get the full path to the file and pass it too the css method.
I would like to suggest you to use php variable as style class and use it directly as css class. For example.
$class1 = "border : 1px solid #eeeeee; font-family : font1, font2, font3; color : #785634;"
And use it in your email template as
<div id='my-div' style=<?php echo $class1; ?>>Your div content </div>
Even I do not know any way to include style sheet in the email, and if you create some classes those will not work in email templates.
So this is how I'm using css in my projects.
you can put the css in email layout like normal html (use html email layout)
<style type="text/css"></style>
Reviewing the code of the htmlHelper shows that it can't be done.
However, you can change or overload the helper; to do so in the simplest way just add a new option between line 371 to 378.
I used PHP's include function enclosed in a script tag and it worked perfectly! In the default email view:
<script>
include('css/your_css_doc.css');`
</script>
You can write css inline:
<h2 style="color:#818381">Here are the latest stories everyone's talking about...</h2>
I get into a problem... I use for all the sponsor links on the site a target="_blank" which is an option that you can select into the WYSIWYG editor of wordpress (no hack).
So if this option IS availible, why doesn't it validate?
And if to validate you have to be in non strict mode why the strict mode is defined?
I know there is a JavaScript hack.. but I don't what to go that way!....
Solution anybody?
That fragment seems to validate as HTML 4.01 Transitional and HTML 5. Validation is nothing without a doctype, what's yours?
After much research... i go with the have... instead of using target="_blank" i use a class="external" and use javascript to change all class to target blank... it validate and work fine...
Im using jquery UI's tabs with ajax.
I was wondering if the files that the ajax calls are gonna retrieve are supposed to be formatted starting with <html> or just the minimal html possible cause its gonna be injected into an already formatted valid xhtml file.... I hope Im making myself clear.
Thanks in advance.
If you're going to inject what you receive from the server directly into the DOM, you'll want an HTML snippet. Something like
<div>This is something <strong>injected</strong></div>
is preferred over
<html><body><div>This is something <strong>injected</strong></div></body></html>
Minimal html. All the examples on the jquery UI tabs page use HTML shards.
You should be able to spit out the HTML exactly as you would want it dropped in to place (i.e. enclosing tags are not necessary).
One SEO advice we got was to move all javascript to external files, so the code could be removed from the text. For fixed scripts this is not a problem, but some scripts need to be generated as they depend on some ClientId that is generated by asp.net.
Can I use the ScriptManager (from asp.net Ajax or from Telerik) to send this script to the browser or do I need to write my own component for that?
I found only ways to combine fixed files and/or embedded resources (also fixed).
How about registering the ClientIDs in an inline Javascript array/hash, and have your external JS file iterate through that?
Spiderbots do not read JavaScript blocks. This advice is plain wrong.
Some javascript can break W3C validators (and possibly cause issues with some spiderbots)
You can reduce this by placing this code around your javascript:
< !-- no script
... your javascript code and functions ...
// -->
Note: remove the space between "<" and "!" as it seems to comment out the example here :-)