Jump to content
Server Maintenance This Week. ×

Get the result after the body onload="function"


Franco Pagano

This topic is 3181 days old. Please don't post here. Open a new topic instead.

Recommended Posts

The following code in a web viewer produce a response like "errno=0&desc=SMS Queued&SmsIndex=34", how to get it in to a filemaker field?

I Nead to get it without plug in, it should work also for the IOS platform.

Many thank for your help.

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>
  <head>
 <script>
 function post(path, params) {
      method = 'post';
      var form = document.createElement('form');
      form.setAttribute('method', method);
      form.setAttribute('action', path);         

      for(var key in params) {
          if(params.hasOwnProperty(key)) {
              var hiddenField = document.createElement('input');
              hiddenField.setAttribute('type', 'hidden');
              hiddenField.setAttribute('name', key);
              hiddenField.setAttribute('value', params[key]);

              form.appendChild(hiddenField);
            }
      }

      document.body.appendChild(form); 
      form.submit();
}
 </script>
  </head>
  <body onload="post('http://192.168.1.99/smssend.cgi' {Pwd: '1234','Push': 0, num: '335xxxx', text:'My  sms machine Text'})">
 
  </body>
</html>

Link to comment
Share on other sites

First you need to grab the content of the web viewer. Use GetLayoutObjectAttribute() for that.

You'll also want to check that the page has finished loading by ensuring the </html> tag is present.

Then you'll want to find the position of both the onload=" string the the subsequent close brackets. There are several functions that you'll probably want to use: Let(), PatternCount(), Position(), and Middle().

Link to comment
Share on other sites

i already tested GetLayoutObjectAttribute(), it give me only the html page without the result of the "<body onload=......" function.

This is the tipycal text result ".....errno=0&desc=SMS Queued&SmsIndex=34...", i need to grab this text coming out from the sms hardware machine.

 

this is what i get using GetLayoutObjectAttribute() with option "content":


 <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>
<html>   
<head>
 <script>  function post(path, params) {
       method = 'post';       
var form = document.createElement('form');       f
orm.setAttribute('method', method);       
form.setAttribute('action', path);                
for(var key in params) {           
if(params.hasOwnProperty(key)) {               
var hiddenField = document.createElement('input');               
hiddenField.setAttribute('type', 'hidden');               
hiddenField.setAttribute('name', key);               
hiddenField.setAttribute('value', params[key]);               f
orm.appendChild(hiddenField);             }       }       
document.body.appendChild(form);       
form.submit(); }  
</script>   
</head>   
<body onload="post('http://192.168.1.99/smssend.cgi' {Pwd: '1234','Push': 0, num: '335xxxx', text:'My  sms machine Text'})">  
 </body>
</html>

Edited by Franco Pagano
Link to comment
Share on other sites

GetLayoutObjectAttribute() accesses the HTML code passed to the web-viewer, not the DOM (same as View Page Source does in a regular browser).

You might have more luck using the Insert From URL[] script step:
http://www.filemaker.com/help/14/fmp/en/html/scripts_ref1.35.50.html#1144726

Or perhaps try the fmp:// protocol to send the values back to Filemaker:
http://www.filemaker.com/help/14/fmp/en/html/sharing_data.17.6.html

Edited by comment
Link to comment
Share on other sites

i don't know how to transform the Dom text to a variable to send to filemaker using the fmp:// protocol.

about Insert From URL[] the post doesn't work with the sms machine hw, i have to use the javascript.

Thanks for your attentions

Link to comment
Share on other sites

This topic is 3181 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.