Show HTML form via Javascript document.write?

If I manage to use this code, please forgive me, but is it possible to use something like

var url = 'http://www.maxcashtitleloans.com/lmapp.html' document.write('<script src="'+url+'"></scr'+'ipt>') 

to somehow display the html form inside many websites on different servers?

I have one HTML form that will be constantly updated as the needs of the company change and wants to disconnect them from IFRAME calls.

Various questions for the same purpose, "How can I display site content on a website, and not use IFRAME"

I know about an affiliate marketing company that uses

 <script type='text/javascript'> var inputOptions = { UserID: '35696', Product: 'payday', ProductTemplate: 'lights', Server: 'https://altohost.com/', mobileDevices: true, parseDefaultValue: true, visitor: { referrer: (document.cookie.match("rfrrr[\r\n\t ]*=[\r\n\t ]*(.*?)(;|$)") || [,''])[1], subaccount: (document.cookie.match("src[\r\n\t ]*=[\r\n\t ]*(.*?)(;|$)") || [,''])[1], keyword: (document.cookie.match("kwrd[\r\n\t ]*=[\r\n\t ]*(.*?)(;|$)") || [,''])[1], clickid: (document.cookie.match("clcid[\r\n\t ]*=[\r\n\t ]*(.*?)(;|$)") || [,''])[1] }, }; document.write('<scr'+'ipt type="text/javascript" src="https://altohost.com/system/applicationforms/init.php?vn=inputOptions"></scr'+'ipt>'); </script> 
+4
source share
5 answers

Ok, there is a solution for you. Your embed code is as follows:

 <script> var url = 'http://www.maxcashtitleloans.com/lmapp.js' document.write('<script src="'+url+'"></scr'+'ipt>') </script> 

And http://www.maxcashtitleloans.com/lmapp.js :

 function ajaxex() { var xmlhttp; if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); }else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200){ document.write(xmlhttp.responseText); } } xmlhttp.open("GET","lmapp.htm",true); xmlhttp.send(); } ajaxex(); 

It works well. And a demo for you: http://commention.com/lmappjsexample/ This solution, such as a javascript proxy, you need to create a javascript file to render your html page.

+1
source

I would suggest a slightly different approach.

Use JavaScript to create the HTML form and include this script in all other websites using the same source.

Suppose form.js is the file that you want to include on every website.

Live demo

forms.js

 var company = {};// Avoid name clashes!!! company.form = function() { this.render(); }; company.form.prototype.render = function() { var url = "blablabla"; this.form = document.createElement("form"); this.form.setAttribute("method", "post"); this.form.setAttribute("name", "company-specialform"); this.form.setAttribute("action", url); var input = document.createElement("input"); input.setAttribute("type", "text"); input.setAttribute("value", "test"); var submit = document.createElement("input"); submit.setAttribute("type", "submit"); submit.setAttribute("value", "submit"); this.form.appendChild(input); this.form.appendChild(submit); var that = this; this.form.onsubmit = function(event) { that.submit.call(that, event); }; }; company.form.prototype.submit = function(event) { event.preventDefault(); // if needed alert(" Custom submit was called"); }; company.form.prototype.getForm = function() { return this.form; }; company.form.append = function(container) { var form = new company.form(); container.appendChild(form.getForm()); }; var target = document.getElementById("container"); company.form.append(target); 

Now just add forms.js to any other website, but make sure you use the same src for all of these websites so that you can update the script.

Now, on each of these websites, they can add a form using company.form.append(someDiv) , and when updating the script, the update will be available on all websites.

+2
source

You can use simple jQuery:

 <script> $('body').load(url); </script> 
0
source

well, the <script> is for enabling javascript, not HTML. Do you want to watch ajax . You want to load the html file via ajax in the div.

Alternatively, leave it as an iframe. Iframes are designed to include one page in another.

Edit The example that you included in the partnership does not make sense to you. They load javascript, which is generated programmatically from the server side of the PHP script based on the input of cookies on the client side. You are trying to load an external html file, these are two different tasks.

javascript in your HEAD tag

 <!-- Include the jquery library - never re-create the wheal --> <script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.min.js'></script> <script type='text/javascript'> $(document).ready(function() { // Run once the page is loaded $('#putFormHere').load('http://www.maxcashtitleloans.com/lmapp.html'); }); </script> 

Replace current iframe with this

 <div id='putFormHere'></div> 

Assumption

I assume that www.maxcashtitleloans.com is the same domain as your current page. If not, then only one way to do this is through an iframe. Javascript does not support cross-site scripting.

0
source
Tags

Scripts do not support HTML. You have to add HTML rendering to your html page. Perhaps you can add this code to your html page. This code displays your html codes in javascript.

 document.write($(body).html()); 
-2
source

Source: https://habr.com/ru/post/1481831/


All Articles