JavaScript - Set Cookies Or Subscribe To View Post
Basic steps:
A user loads the web page Wants to view a post by clicking Read more... A message box appears "Subscribe to view the article" Quote: If the user is subscribed, they view without any message boxes, links or redirects. What is the best practice to allow a user to view an entire post by clicking a Read more... only after subscribing? Similar TutorialsI have 10 feedburner feeds that are for different categories on a wordpress site. I would like to modify the subscribe form code feedburner supplies to include radio buttons to select which of the feeds to subscribe to. Code: <HTML> <HEAD> <TITLE> Radio Window </TITLE> <script> function OpenWindow(){ for(i=0;i<document.FormName["RB1"].length;i++){ if(document.FormName["RB1"][i].checked){ window.open(document.FormName["RB1"][i].value); break; } } } </script> </HEAD> <BODY> <form name="FormName" style="border:1px solid #ccc;padding:3px;text-align:center;" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popupwindow" onsubmit="OpenWindow()";return true"> <p>Enter your email address:</p><p><input type="text" style="width:140px" name="email"/></p> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed1&loc=en_US">Option 1<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed2&loc=en_US">Option 2<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed3&loc=en_US">Option 3<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed4&loc=en_US">Option 4<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed5&loc=en_US">Option 5<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed6&loc=en_US">Option 6<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed7&loc=en_US">Option 7<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed8&loc=en_US">Option 8<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed9&loc=en_US">Option 9<BR> <input type="radio" name="RB1" value="http://feedburner.google.com/fb/a/mailverify?uri=feed10&loc=en_US">Option 10<BR> <input type="submit" value="Subscribe"> </form> </BODY> </HTML> This is the code I have put together searching the web, when hitting the subscribe button after entering a email address and selecting an option it load two new windows, one for the relevant feed but does not transfer the email address entered in the text box. The second for to http://feedburner.google.com/fb/a/mailverify All help would be greatly received. In a webpage I am developing I need to change the presentation depending on user selection. At the moment this code is huge and not very maintainable. The first purpose was to have a working code, now I would like to make it more maintainable. Below is a main part of the problem; Code: function myFunction(type) { if (type.value == "1") { var form1 = document.getElementById("OrderForm1"); form1.style.display = "block"; var form2 = document.getElementById("OrderForm2"); form2.style.display = "none"; var form3 = document.getElementById("OrderForm3"); form3.style.display = "none"; } else if (type.value == "2") { var form1 = document.getElementById("OrderForm1"); form1.style.display = "none"; var form2 = document.getElementById("OrderForm2"); form2.style.display = "block"; var form3 = document.getElementById("OrderForm3"); form3.style.display = "none"; } else if (type.value == "3") { var form1 = document.getElementById("OrderForm1"); form1.style.display = "none"; var form2 = document.getElementById("OrderForm2"); form2.style.display = "none"; var form3 = document.getElementById("OrderForm3"); form3.style.display = "block"; } } <div id="OrderForm" style="display: block;"> <div id="OrderForm1" style="display: none;"> <FORM METHOD="POST"></FORM> </div> <div id="OrderForm2" style="display: none;"> <FORM METHOD="POST"></FORM> </div> <div id="OrderForm3" style="display: none;"> <FORM METHOD="POST"></FORM> </div> </div> Basically the myFunction will be called based on user input. This input will show one section of html code and hide other sections of html code. So if input is "1", then OrderForm1 shall be shown and OrderForm2 and OrderForm3 must be hidden. if input is "2", the OrderForm2 shall be shown and OrderForm1 and OrderForm3 must be hidden etc. By adding more forms to show and hide, this code is growing massively. I would like to add some kind of for loop function to this but I am not sure how to loop through the various section names (OrderForm1, OrderForm2 and OrderForm3) and set the appropriate value. Appreciate any help HI , IF there is error in JS then in FF i can see in console window using firebug But i am noe getting script error in IE but i am not able to find where the error is. Is says object required line 499 now i don't understand which script is IE talking about . Is there any way to find error in IE Hi Sorry if the title is a bit vague. I have a single page with fixed background and <A name=section> / #section type menu also have a margin-bottom: 1000px; so content isnt visible until the link in menu is pressed I am using the smooth pack javascript so it scrolls rather than jumps straight to the #section content what I want to do is have the content invisible until it reaches the fixed background is it possible to have content invisible until it scrolls into a div, i'm sure it is the fixed background is about 800x500 and black all round so the text is visible, I could alter to have any text black but at the moment its blue and white If there is no street view available for a specific long and lat on google maps, is there a way to display some kind of message instead of the grey box which google shows? I cant find anything in the API?
What is the code to stop people from viewing your source. Such as this site: http://bad-behavior.com (View The Source of That Site) I've searched the forums, and all I got was a bunch of "nothing can protect your source" I don't care about all of that. I want the code because: 1. Most people don't know how to view a source after it has been blocked 2. I think it's cool Hi , I made a table that retrieves some Data from the Database also I did some calculations for this data using Javascript and It works fine , but I can't see the calculated values in the source code . That's the Problem , cause I can't print it or export it without these values. and the source code doesnt show it... so , what can I do , to view the generated values from JS in the source code ?? Thanks , I'm afraid this is a task related to my job and I need ur Help Urgently I'm using IE 6 only as a web browser and the Javascript Calculations are functions and Classes in a seperated file and I linked it to the Report page ... My goal is to have one big picture center with 4 smaller pictures to the left that you click on and is target to the center. When you click on the center it will zoom. I haven't worked on it in a few years and not able to find the person who wrote the code. I added the zoom coding to the picture switch. The zoom works fine but when you click the smaller images the image is not viewable. Coding in the head Code: <!--Image Viewer--> <script language="javascript" type="text/javascript"> <!-- function canManipulateImages() { if (document.images) return true; else return false; } // loadPosterImage function loadPosterImage(imageURL) { if (gImageCapableBrowser) { document.imagePoster.src = imageURL; return false; } else { return true; } } gImageCapableBrowser = canManipulateImages(); // --> </script> <!--End Image Viewer--> <!--Picture Zoom--> <script> // C.2004 by CodeLifter.com var nW,nH,oH,oW; function zoomToggle(iWideSmall,iHighSmall,iWideLarge,iHighLarge,whichImage){ oW=whichImage.style.width;oH=whichImage.style.height; if((oW==iWideLarge)||(oH==iHighLarge)){ nW=iWideSmall;nH=iHighSmall;}else{ nW=iWideLarge;nH=iHighLarge;} whichImage.style.width=nW;whichImage.style.height=nH; } </script> <!--End Picture Zoom--> The body code Code: <!--Picture #4--> <tr> <td><A href="F:\mamies\santa_pic\purple_bottom.gif" onClick="return(loadPosterImage('F:\mamies\santa_pic\purple_bottom.gif'))"> <img src="F:\mamies\santa_pic\purple_bottom.gif" border=1 align=center width=56 height=75></A> </td> </tr> </table> <table align="center" border="1" cellspacing="0" cellpadding="5" height="10" bgcolor="#002152" bordercolor="#980008"> <tr> <!--Image Zoom--> <td><img name="imagePoster" src="F:\mamies\santa_pic\purple_front.gif" border="0" width="354" height="502" onclick="zoomToggle('354px','502px','708px','1004px',this);"> <!--End Image Zoom--> Thanks for your help Charlene Hi everyone, While designing my www I used the tab view script made by Lyubinskiy found on javascript kit www. It works brilliant on mozzila and chrome. However when I tried on safari and IE, the tabs don't work. Can anyone tell me how should I adjust the sript for it to work on IE and Safari? Code: function tabview_aux(TabViewId, id) { var TabView = document.getElementById(TabViewId); // ----- Tabs ----- var Tabs = TabView.firstChild; while (Tabs.className != "Tabs" ) Tabs = Tabs.nextSibling; var Tab = Tabs.firstChild; var i = 0; do { if (Tab.tagName == "A") { i++; Tab.href = "javascript:tabview_switch('"+TabViewId+"', "+i+");"; Tab.className = (i == id) ? "Active" : ""; Tab.blur(); } } while (Tab = Tab.nextSibling); // ----- Pages ----- var Pages = TabView.firstChild; while (Pages.className != 'Pages') Pages = Pages.nextSibling; var Page = Pages.firstChild; var i = 0; do { if (Page.className == 'Page') { i++; if (Pages.offsetHeight) Page.style.height = (Pages.offsetHeight-2)+"px"; Page.style.overflow = "auto"; Page.style.display = (i == id) ? 'block' : 'none'; } } while (Page = Page.nextSibling); } // ----- Functions ------------------------------------------------------------- function tabview_switch(TabViewId, id) { tabview_aux(TabViewId, id); } function tabview_initialize(TabViewId) { tabview_aux(TabViewId, 1); } thanks for any suggestions Hi, I'm creating an extension on Firefox that wishes to parse the source of a page that the user is currently viewing for specific information. I've gotten as far as creating a simple extension with a button and when I click on it, it will show the url of the page I am currently viewing through: content.location.href All the examples I've seen so far concerning viewing the source forces you to either use the 'view-source:' convention or the 'xmlhttprequest' method. But these examples seems to be meant to be called within a web page and not an extension. When I cut and paste with these examples, I only get the source for the actual chrome portion of Firefox. I've tried modifying some of the examples to include 'content.document....etc' to reference what's being displayed in the browser, but it doesn't seem to work. Can anyone provide sample or reference code so I can extract the page source of my current window from an extension? Thanks! How do I hide my javascript from html page (from view source on right click)?
I have a dataTable in which on the keyup event, the cursor focuses to the next field. In IE7, after a field, the next field is not coming into the view. Please help. The occField(2nd attachment) comes into view only after focus moves to next field, i.e LTD Buy up. Code: if (currId.indexOf("Occ") >= 0) { if(stdBuyUpSelected){ autoTabFocus("SBuy",index); }else if(ltdBuyUpSelected){ autoTabFocus("LBuy",index); } else if (isStateZipDisp){ autoTabFocus("Zp",index); } } function autoTabFocus(next,index) { var focusElem = document.getElementById(next+index); if (focusElem != null) { focusElem.focus(); } } I am making a site HERE and I was using this: Code: <script> if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile/i.test(navigator.userAgent)) { if (document.URL != "http://www.precisionpaintandcollision.net") { window.location = "http://m.precisionpaintandcollision.net"; } } </script> to auto-redirect mobile users to the mobile site and I want to keep that but I want them to be able to view the desktop site without that code affecting them. I know some apps have "force/request desktop site" but i'd like them to be able to just view the desktop site without auto redirecting to mobile site. Is this possible? Thanks -John I have created and opened a new window using Javascript and written to it with the document.write Command. When I click "View" and then "Page Source" (Firefox) to view the source of it, however, it displays a blank page. How can I get the source of a window I created? Thank You Charles Hi - I'm working in ASP.Net 2.0. My page has a GridView control, which is populated by a SQLDataSource. The GridView has one Button control per row. The button has a client-side javascript function (ShowDelete) attached to its OnClientClick event on DataBinding of the GridView. This event fires some javascript. The javascript does 3 things: - It changes the text of the button from "Hide" to "Create" - It changes the background color of the button from red to green - It assigns a new onClientClick event to the button: "ShowAvailable" The text and the color of the button change with no problem. After I change the OnClientClick event, I send an alert with the button's OnClientClick event and it reports it to be "ShowAvailable". However, when I click on the button, it doesn't fire ShowAvailable, it fires the original onClientClick event (ShowDelete). Also, when I do View Source, it shows the button's text, color and OnClientClick event as their original settings, i.e., "Hidden", "Red" and "ShowDelete", even though I'm looking at a green button that says "Create." What's going on here? Here's the code I use to attach the OnClientClick event on DataBinding of the GridView: Code: foreach (GridViewRow row in this.gvLocation.Rows) { if (row.RowType == DataControlRowType.DataRow || row.RowType == DataControlRowType.EmptyDataRow) { int rowindex = row.RowIndex + 1; //to exclude the header which is counted as a row when we get to javascript btnAction.OnClientClick = "ShowDelete(" + rowindex.ToString() + "); return false"; } } Here's the javascript for ShowDelete: Code: function ShowDelete(rowindex) { var locationgridID = '<%= gvLocation.ClientID %>'; locationgrid = document.getElementById(locationgridID); if (locationgrid != null) { action_cell = locationgrid.rows[rowindex].cells[3]; for (k = 0; k < action_cell.childNodes.length; k++) { if (typeof(action_cell.childNodes[k].id) == 'string') { action_cell.childNodes[k].value = "Create"; action_cell.childNodes[k].style.backgroundColor = "Green"; action_cell.childNodes[k].onclientclick = "ShowAvailable(" + rowindex + "); return false"; alert(action_cell.childNodes[k].onclientclick); // reports the OnClientClick event is ShowAvailable } } } } Any thoughts are greatly appreciated! Hi, Following this jQuery slideshow tutorial (Usecase 3 sample, about 2/3 down the page, this is the one without thumbnails): http://www.gcmingati.net/wordpress/w...vwt/index.html I constructed the slideshow: http://backstageweb.net/Salon/slideshowcode.htm ...which works perfectly in browser view locally (FF and IE). When uploaded to the server, however, I've got a static list of photos as you can see. Can someone shed some light on what the problem is? All relevant files are attached (I changed the images to simple colors to get the file size within the attachment limit). Thanks. John Hi all, I need some help. I have a javascript thing on my site that changes the css layout from standard to alternate, and that works fine. Now I am wondering if it's possible for it to store a cookie, that when any of the pages on my site (this javascript thing is on every page) are re-loaded or the user navigates to a different page, it will keep the alternate stylesheet. Then, when it is changed back, the cookie gets deleted. Here's my code: Header: Code: <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" title="default" /> <link rel="alternate stylesheet" href="/wp-content/themes/new/darkside.css" type="text/css" media="screen" title="darkside" /> <script language="javascript" src="/wp-content/themes/new/darkside.js"></script> Darkside.js Code: // *** TO BE CUSTOMISED *** var style_cookie_name = "style" ; var style_cookie_duration = 30 ; // *** END OF CUSTOMISABLE SECTION *** function switch_style ( css_title ) { // You may use this script on your site free of charge provided // you do not remote this notice or the URL below. Script from // http://www.thesitewizard.com/javascripts/change-style-sheets.shtml var i, link_tag ; for (i = 0, link_tag = document.getElementsByTagName("link") ; i < link_tag.length ; i++ ) { if ((link_tag[i].rel.indexOf( "stylesheet" ) != -1) && link_tag[i].title) { link_tag[i].disabled = true ; if (link_tag[i].title == css_title) { link_tag[i].disabled = false ; } } set_cookie( style_cookie_name, css_title, style_cookie_duration ); } } function set_style_from_cookie() { var css_title = get_cookie( style_cookie_name ); if (css_title.length) { switch_style( css_title ); } } function set_cookie ( cookie_name, cookie_value, lifespan_in_days, valid_domain ) { // http://www.thesitewizard.com/javascripts/cookies.shtml var domain_string = valid_domain ? ("; domain=" + valid_domain) : '' ; document.cookie = cookie_name + "=" + encodeURIComponent( cookie_value ) + "; max-age=" + 60 * 60 * 24 * lifespan_in_days + "; path=/" + domain_string ; } function get_cookie ( cookie_name ) { // http://www.thesitewizard.com/javascripts/cookies.shtml var cookie_string = document.cookie ; if (cookie_string.length != 0) { var cookie_value = cookie_string.match ( '(^|;)[\s]*' + cookie_name + '=([^;]*)' ); return decodeURIComponent ( cookie_value[2] ) ; } return '' ; } EDIT: Actually, this is what happens: The user enters the konami code and a div shows/hides. There you are given the option to turn off/on the alternate style. Then I want the cookie to begin.. Hi, Im a bit stuck on something, any help is greatly appreciated. I want a user to input a name, age, gender, city into a form, this gets stored in some cookies and when they click submit they are taken to another page where their details are displayed in the webpage. Thanks for the help. If I create a cookie in PHP here. PHP Code: setcookie('cookie_cl_'.$client_id, 'cookie_cl_'.$client_id, $time, "/","", 0); the php script is set on domain B the javascript I want to read the cookie is set on domain B as well However, the hosted on DOMAIN A Code: <script src=domain B .js> I want the cookie to remain on domain B, but if I open the JS file using domain A, both php and JS are using domain B, though I can't seem to get the JS to find the cookie, is it looking at domain A ? am I suppose to set a domain on cookie for this to work? Hopefully this makes sense. |