Advertisement
firoze

Placeholders.js For IE Support and Allow Blocked Content

Jan 3rd, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. <!-- First call this before the </body> -->
  2. <!--[if IE]>
  3. <script src="js/placeholder.iesupport.js"></script>
  4. <![endif]-->
  5. <!--[if IE]>
  6. <script src="http://jamesallardice.github.io/Placeholders.js/assets/js/placeholders.min.js"></script>
  7. <![endif]-->
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17. <!-- This for placeholder input IE support js save this js name like placeholder.iesupport.js and put into your js file -->
  18. // placeholder IE support js
  19. jQuery(function() {
  20. jQuery.support.placeholder = false;
  21. webkit_type = document.createElement('input');
  22. if('placeholder' in webkit_type) jQuery.support.placeholder = true;});
  23. $(function() {
  24.  
  25. if(!$.support.placeholder) {
  26.  
  27. var active = document.activeElement;
  28.  
  29. $(':text, textarea, :password').focus(function () {
  30.  
  31. if (($(this).attr('placeholder')) && ($(this).attr('placeholder').length > 0) && ($(this).attr('placeholder') != '') && $(this).val() == $(this).attr('placeholder')) {
  32. $(this).val('').removeClass('hasPlaceholder');
  33. }
  34. }).blur(function () {
  35. if (($(this).attr('placeholder')) && ($(this).attr('placeholder').length > 0) && ($(this).attr('placeholder') != '') && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
  36. $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
  37. }
  38. });
  39.  
  40. $(':text, textarea, :password').blur();
  41. $(active).focus();
  42. $('form').submit(function () {
  43. $(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
  44. });
  45. }
  46. });
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. <!-- This for placeholder input IE support css save this css name like specific-browser.css and put into your css file-->
  60. /*
  61. Firefox
  62. */
  63.  
  64. @-moz-document url-prefix() {
  65.  
  66. .right_content{width:760px;float:left;text-align:left;display:inline;}
  67.  
  68. :-moz-placeholder { color: rgba(255,0,0,0.4) !important; }
  69.  
  70. /*start to write your specific browser css here*/
  71.  
  72. }
  73.  
  74. /*
  75. Chrome + Safari + Opera
  76. */
  77.  
  78. @media screen and (-webkit-min-device-pixel-ratio:0) {
  79.  
  80. .right_content{width:760px;float:left;text-align:left;display:inline;}
  81.  
  82. ::-webkit-input-placeholder { color: rgba(900,0,0,0.900) !important; }
  83. /*start to write your specific browser css here*/
  84.  
  85. }
  86.  
  87. /*
  88. Internet Explorer 10
  89. */
  90. @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
  91.  
  92. .right_content{width:760px;float:left;text-align:left;display:inline;}
  93. input:-ms-input-placeholder{color: rgba(255,0,0,0.75);}
  94. /*start to write your specific browser css here*/
  95.  
  96. }
  97.  
  98.  
  99. /*textarea color not support for IE ALL*/
  100. /*
  101. Internet Explorer 9-10
  102. */
  103. @media screen and (min-width:0\0) {
  104.  
  105. .right_content{width:760px;float:left;text-align:left;display:inline;}
  106.  
  107. input.hasPlaceholder{color:red}
  108.  
  109.  
  110. }
  111. /*
  112. Internet Explorer 8
  113. */
  114. @media \0screen\,screen\9 {
  115.  
  116. .right_content{width:760px;float:left;text-align:left;display:inline;}
  117.  
  118. input.hasPlaceholder{color:red}
  119. }
  120.  
  121. /*
  122. Internet Explorer 7
  123. */
  124. @media screen\9 {
  125.  
  126. .right_content{width:760px;float:left;text-align:left;display:inline;}
  127.  
  128. input.hasPlaceholder{color:red}
  129.  
  130. }
  131.  
  132.  
  133. /*
  134. ONLY FOR OPERA
  135. */
  136. @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {
  137. input.hasPlaceholder{color:red}
  138. #my-id { clear:right; }
  139.  
  140. }
  141.  
  142. /*
  143. only for safari
  144. */
  145. @media screen and (-webkit-min-device-pixel-ratio:0) {
  146. input.hasPlaceholder{color:red}
  147. #my-id { height: 100%; }
  148.  
  149. }
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. <!--placeholdercolor textarea text color IE support css put this css into your style.css -->
  166. .hasPlaceholder{color:red}
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182. <!-- if you want to do automatically Allow Blocked Content in IE then use the bellow code before <html> -->
  183.  
  184. <!-- saved from url=(0014)about:internet -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement