webpage - Please how can i get current html page title and pass to submit form -
pls want script in javascript only. want page title , pass submit form, when being submited, can see actual page name user sent request from.
try using jquery
$(document).find("title").text(); or in generic way
var title = document.getelementsbytagname("title")[0].innerhtml; update
you can append item in form this
function appendhiddenfield(theform) { // create hidden input element, , append form: var input = document.createelement('input'); input.type = 'hidden'; input.name ='pagetitle'; var pagetitle = document.getelementsbytagname("title")[0].innerhtml; input.value = pagetitle; theform.appendchild(input); } you can use function append hidden field form before submitting it.
update here working code need assign form id.
js
window.onload = function(){ var input =document.createelement('input'); var frm = document.getelementbyid("myform"); input.type = 'hidden'; input.name ='pagetitle'; input.value = document.title; frm.appendchild(input); } html
<form id="myform" method="submit" action="http://www.facebook.com/sharer/sharer.php?u=http://lmn.9nty.com/?testlink=www.learnmoreng.com/site_rp.xhtml"> <input type="text" name="l" value=":getid-url:" maxlength="20" size="9"/> <input type="submit" value="share" style="background-color:#f3f4f5;padding:3;color:#339900;font-weight:italic"/></form>
Comments
Post a Comment