Solved

ust html in ms/access WebBrowswer

Posted on 2016-10-11
11
41 Views
Last Modified: 2016-11-16
In order to have control  of the parameters that I need to send to google maps (to be shown embedded in a control on a web form, according to Google Maps, I need to be able to "store" either a javascript or a html script in it, for which I can find no manner to do.

By googling a bit, I found the following suggestion on stack exchange:

Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

QUOTE
With Me.WebBrowser6.Object
    .Navigate2 "about:blank"
    .Document.write rst.Fields(2)
    .Refresh
End With

UNQUOTE

but nothing happens

can anyone help me?
0
Comment
Question by:jirdeaid
  • 6
  • 4
11 Comments
 
LVL 32

Expert Comment

by:Stefan Hoffmann
ID: 41840407
Well, I decided to use the ActiveX WebBrowser control instead of the native WebBrowser for Access 2010/2013 since the former accepts the html string and formats the document correctly by using the write property of the document.

D'oh? WebBrowser can do this also.

But .Refresh is not necessary nor does it something useful here.
0
 

Author Comment

by:jirdeaid
ID: 41840502
The question is: How does it?
0
 
LVL 32

Accepted Solution

by:
Stefan Hoffmann earned 500 total points
ID: 41840526
Misunderstood your post. Use ActiveX instead:

With Me.WebBrowser6.Object
     .Navigate "about:blank"
     .Document.write "<h1>Test</h1>
 End With

Open in new window

Q28975670.accdb
0
 

Author Comment

by:jirdeaid
ID: 41840631
Thanks a lot.

A thanks for the example.

So, it I replace "<h1>Test<h1> and using the proper CR chars, wuth

<!DOCTYPE html>
<html>
    <head>
        <title>createPushpinFromCanvasHTML</title>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    </head>
    <body>
        <div id='printoutPanel'></div>
       
        <div id='myMap' style='width: 100vw; height: 100vh;'></div>
        <script type='text/javascript'>
            function loadMapScenario() {
                var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials:                     'Your Bing Maps Key'
                });
                var pushpin = new Microsoft.Maps.Pushpin(map.getCenter(), {
                    icon: createRedArrow(45),
                    anchor: new Microsoft.Maps.Point(12, 12)
                });
                map.entities.push(pushpin);
                function createRedArrow(heading) {
                    var c = document.createElement('canvas');
                    c.width = 24;
                    c.height = 24;
                    var ctx = c.getContext('2d');
                    // Offset the canvas such that we will rotate around the center of our arrow
                    ctx.translate(c.width * 0.5, c.height * 0.5);
                    // Rotate the canvas by the desired heading
                    ctx.rotate(heading * Math.PI / 180);
                    //Return the canvas offset back to it's original position
                    ctx.translate(-c.width * 0.5, -c.height * 0.5);
                    ctx.fillStyle = '#f00';
                    // Draw a path in the shape of an arrow.
                    ctx.beginPath();
                    ctx.moveTo(12, 0);
                    ctx.lineTo(5, 20);
                    ctx.lineTo(12, 15);
                    ctx.lineTo(19, 20);
                    ctx.lineTo(12, 0);
                    ctx.closePath();
                    ctx.fill();
                    ctx.stroke();
                    // Generate the base64 image URL from the canvas.
                    return c.toDataURL();
                }
               
            }
        </script>
        <script type='text/javascript' src='http://www.bing.com/api/maps/mapcontrol?branch=release&callback=loadMapScenario' async defer></script>
    </body>
</html>

will it work?

by
0
 
LVL 32

Expert Comment

by:Stefan Hoffmann
ID: 41840713
Basically, yes. But the question is: Why not storing this as local HTML file and distributing it with your database file?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jirdeaid
ID: 41840751
You are right!

My problem is "theoretically" quite simple:

I want to show some points for which, in my database, I do have GPS coordinates some pushpins, an text that depend on the type of point. Like this:

PointRef     Lat    Lon   Type        Text
r1                 La1   Lo1   Ty1          Txt1
r2                 La2   Lo1   Ty2          Txt2
r3                 La2   Lo1   Ty2          Txt2


So I want to plot in a map, Google Maps or Bing those 3 points. The map is to be shown inside the WebBrowser.

the code I have sent you is exactly the code that microsoft uses as example to use Bing:

http://www.bing.com/api/maps/sdk/mapcontrol/isdk#createPushpinFromCanvas+JS

so it easy for me just to alter it to my specific case, but I can also use Google Maps.

what would be your suggestion?
0
 
LVL 32

Expert Comment

by:Stefan Hoffmann
ID: 41840793
Pretty simple: Inject the data.

Create JavaScript function to take the data as parameter and call it from Access.

Apparently I'm writing an article about it. So when you can wait some days..
0
 

Author Comment

by:jirdeaid
ID: 41840831
Well... I don't know anything about javascript, so it is, right now, beyond my capabilities. However, if your article, is able to provide easy examples, I will follow it immediately! - how can I know about it? (my email?:joao.serras.pereora@ware.pt)

anyway, I am sending you the database with the "new" code that I have sent you, but it does not work: a totally white page is what is shown... I am sure that the error is mine, and if I can't get to a solution I'll ask a new question...

I am closing this page
Q28975670.accdb
0
 

Author Comment

by:jirdeaid
ID: 41840835
THANKS!
0
 
LVL 49

Expert Comment

by:Gustav Brock
ID: 41885355
This is because IE is the browser called and it has to run a local script in low security mode. It can be a file you open, or it can be dynamic using strMap:

    WebBrowser.Navigate "about:Blank"
    WebBrowser.Document.Write strMap

but still, the script security will kick in and block.

You may have to run the script off a file from a (local) web server to get passed the strict security.

/gustav
0
 

Author Closing Comment

by:jirdeaid
ID: 41890948
thanks for the help!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now